diff options
Diffstat (limited to 'compiler/rustc_lint/src/context.rs')
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 50bb1fb942e..a67b404e6e1 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -4,7 +4,7 @@ //! overview of how lints are implemented. use std::cell::Cell; -use std::{iter, slice}; +use std::slice; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync; @@ -233,11 +233,14 @@ impl LintStore { } pub fn register_group_alias(&mut self, lint_name: &'static str, alias: &'static str) { - self.lint_groups.insert(alias, LintGroup { - lint_ids: vec![], - is_externally_loaded: false, - depr: Some(LintAlias { name: lint_name, silent: true }), - }); + self.lint_groups.insert( + alias, + LintGroup { + lint_ids: vec![], + is_externally_loaded: false, + depr: Some(LintAlias { name: lint_name, silent: true }), + }, + ); } pub fn register_group( @@ -252,11 +255,14 @@ impl LintStore { .insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None }) .is_none(); if let Some(deprecated) = deprecated_name { - self.lint_groups.insert(deprecated, LintGroup { - lint_ids: vec![], - is_externally_loaded, - depr: Some(LintAlias { name, silent: false }), - }); + self.lint_groups.insert( + deprecated, + LintGroup { + lint_ids: vec![], + is_externally_loaded, + depr: Some(LintAlias { name, silent: false }), + }, + ); } if !new { @@ -718,30 +724,6 @@ impl<'tcx> LateContext<'tcx> { } } - /// Check if a `DefId`'s path matches the given absolute type path usage. - /// - /// Anonymous scopes such as `extern` imports are matched with `kw::Empty`; - /// inherent `impl` blocks are matched with the name of the type. - /// - /// Instead of using this method, it is often preferable to instead use - /// `rustc_diagnostic_item` or a `lang_item`. This is less prone to errors - /// as paths get invalidated if the target definition moves. - /// - /// # Examples - /// - /// ```rust,ignore (no context or def id available) - /// if cx.match_def_path(def_id, &[sym::core, sym::option, sym::Option]) { - /// // The given `def_id` is that of an `Option` type - /// } - /// ``` - /// - /// Used by clippy, but should be replaced by diagnostic items eventually. - pub fn match_def_path(&self, def_id: DefId, path: &[Symbol]) -> bool { - let names = self.get_def_path(def_id); - - names.len() == path.len() && iter::zip(names, path).all(|(a, &b)| a == b) - } - /// Gets the absolute path of `def_id` as a vector of `Symbol`. /// /// # Examples |
