Plumb through rustc_lint_defs::Level as enum rather than string.
This commit is contained in:
parent
39f2f18463
commit
0529a13b5d
@ -212,7 +212,12 @@ fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
|
||||
fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
|
||||
|
||||
/// Emit list of unused externs
|
||||
fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {}
|
||||
fn emit_unused_externs(
|
||||
&mut self,
|
||||
_lint_level: rustc_lint_defs::Level,
|
||||
_unused_externs: &[&str],
|
||||
) {
|
||||
}
|
||||
|
||||
/// Checks if should show explanations about "rustc --explain"
|
||||
fn should_show_explain(&self) -> bool {
|
||||
|
@ -171,7 +171,8 @@ fn emit_future_breakage_report(&mut self, diags: Vec<crate::Diagnostic>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_unused_externs(&mut self, lint_level: &str, unused_externs: &[&str]) {
|
||||
fn emit_unused_externs(&mut self, lint_level: rustc_lint_defs::Level, unused_externs: &[&str]) {
|
||||
let lint_level = lint_level.as_str();
|
||||
let data = UnusedExterns { lint_level, unused_extern_names: unused_externs };
|
||||
let result = if self.pretty {
|
||||
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
|
||||
|
@ -969,10 +969,10 @@ pub fn emit_future_breakage_report(&self, diags: Vec<Diagnostic>) {
|
||||
self.inner.borrow_mut().emitter.emit_future_breakage_report(diags)
|
||||
}
|
||||
|
||||
pub fn emit_unused_externs(&self, lint_level: &str, unused_externs: &[&str]) {
|
||||
pub fn emit_unused_externs(&self, lint_level: rustc_lint_defs::Level, unused_externs: &[&str]) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
|
||||
if lint_level == "deny" || lint_level == "forbid" {
|
||||
if lint_level.is_error() {
|
||||
inner.bump_err_count();
|
||||
}
|
||||
|
||||
@ -1147,7 +1147,7 @@ fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) {
|
||||
self.emitter.emit_artifact_notification(path, artifact_type);
|
||||
}
|
||||
|
||||
fn emit_unused_externs(&mut self, lint_level: &str, unused_externs: &[&str]) {
|
||||
fn emit_unused_externs(&mut self, lint_level: rustc_lint_defs::Level, unused_externs: &[&str]) {
|
||||
self.emitter.emit_unused_externs(lint_level, unused_externs);
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,13 @@ pub fn from_attr(attr: &Attribute) -> Option<Level> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_error(self) -> bool {
|
||||
match self {
|
||||
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn => false,
|
||||
Level::Deny | Level::Forbid => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Specification of a single lint.
|
||||
|
@ -208,10 +208,7 @@ pub fn report_unused_deps(&self, tcx: TyCtxt<'_>) {
|
||||
let unused_externs =
|
||||
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
|
||||
let unused_externs = unused_externs.iter().map(String::as_str).collect::<Vec<&str>>();
|
||||
tcx.sess
|
||||
.parse_sess
|
||||
.span_diagnostic
|
||||
.emit_unused_externs(level.as_str(), &unused_externs);
|
||||
tcx.sess.parse_sess.span_diagnostic.emit_unused_externs(level, &unused_externs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user