- pub fn check_lint_name(&self, lint_name: &str) -> CheckLintNameResult {
- match self.by_name.get(lint_name) {
- Some(&Renamed(ref new_name, _)) => {
- CheckLintNameResult::Warning(
- format!("lint `{}` has been renamed to `{}`", lint_name, new_name),
- Some(new_name.to_owned())
- )
- },
- Some(&Removed(ref reason)) => {
- CheckLintNameResult::Warning(
- format!("lint `{}` has been removed: `{}`", lint_name, reason),
- None
- )
- },
- None => {
- match self.lint_groups.get(lint_name) {
- None => CheckLintNameResult::NoLint,
- Some(ids) => CheckLintNameResult::Ok(&ids.0),
- }
+ pub fn check_lint_name(
+ &self,
+ lint_name: &str,
+ tool_name: Option<LocalInternedString>,
+ ) -> CheckLintNameResult {
+ let complete_name = if let Some(tool_name) = tool_name {
+ format!("{}::{}", tool_name, lint_name)
+ } else {
+ lint_name.to_string()
+ };
+ if let Some(_) = tool_name {
+ match self.by_name.get(&complete_name) {
+ None => match self.lint_groups.get(&*complete_name) {
+ None => return CheckLintNameResult::Tool(None),
+ Some(ids) => return CheckLintNameResult::Tool(Some(&ids.0)),
+ },
+ Some(&Id(ref id)) => return CheckLintNameResult::Tool(Some(slice::from_ref(id))),
+ // If the lint was registered as removed or renamed by the lint tool, we don't need
+ // to treat tool_lints and rustc lints different and can use the code below.
+ _ => {}