-#![deny(rustc::untranslatable_diagnostic)]
-#![deny(rustc::diagnostic_outside_of_impl)]
use crate::context::{CheckLintNameResult, LintStore};
use crate::late::unerased_lint_store;
use crate::lints::{
DeprecatedLintName, IgnoredUnlessCrateSpecified, OverruledAtributeLint, RenamedOrRemovedLint,
- UnknownLint,
+ RenamedOrRemovedLintSuggestion, UnknownLint, UnknownLintSuggestion,
};
use rustc_ast as ast;
use rustc_ast_pretty::pprust;
}
}
-/// Specifications found at this position in the stack. This map only represents the lints
+/// Specifications found at this position in the stack. This map only represents the lints
/// found for one set of attributes (like `shallow_lint_levels_on` does).
///
/// We store the level specifications as a linked list.
match attrs.map.range(..) {
// There is only something to do if there are attributes at all.
[] => {}
- // Most of the time, there is only one attribute. Avoid fetching HIR in that case.
+ // Most of the time, there is only one attribute. Avoid fetching HIR in that case.
[(local_id, _)] => levels.add_id(HirId { owner, local_id: *local_id }),
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
// a standard visit.
_ if !self.warn_about_weird_lints => {}
CheckLintNameResult::Warning(msg, renamed) => {
+ let suggestion =
+ renamed.as_ref().map(|replace| RenamedOrRemovedLintSuggestion {
+ suggestion: sp,
+ replace: replace.as_str(),
+ });
self.emit_spanned_lint(
RENAMED_AND_REMOVED_LINTS,
sp.into(),
- RenamedOrRemovedLint { msg, suggestion: sp, renamed },
+ RenamedOrRemovedLint { msg, suggestion },
);
}
CheckLintNameResult::NoLint(suggestion) => {
} else {
name.to_string()
};
+ let suggestion = suggestion
+ .map(|replace| UnknownLintSuggestion { suggestion: sp, replace });
self.emit_spanned_lint(
UNKNOWN_LINTS,
sp.into(),
- UnknownLint { name, suggestion: sp, replace: suggestion },
+ UnknownLint { name, suggestion },
);
}
}