about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-01-09 06:08:07 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-01-11 07:42:26 +0100
commit16bf2783b5cd5f0a6155094f885890f4c0834477 (patch)
tree7828d4c5b960891b2ae43ae5186861f5ba33d7de
parenteee84fe3960f0bb79f8bf02577bf00aa44302e00 (diff)
downloadrust-16bf2783b5cd5f0a6155094f885890f4c0834477.tar.gz
rust-16bf2783b5cd5f0a6155094f885890f4c0834477.zip
inline maybe_lint_level_root
-rw-r--r--src/librustc/lint/mod.rs6
-rw-r--r--src/librustc/ty/context.rs14
2 files changed, 6 insertions, 14 deletions
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index 371fa27cb24..6eec77d1d90 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -21,7 +21,6 @@
 pub use self::levels::LintSource::{self, *};
 pub use self::Level::*;
 
-use crate::ty::TyCtxt;
 use rustc_data_structures::sync;
 use rustc_hir as hir;
 use rustc_session::lint::builtin::HardwiredLints;
@@ -315,8 +314,3 @@ pub mod internal;
 mod levels;
 
 pub use self::levels::{struct_lint_level, LintLevelMap, LintLevelSets, LintLevelsBuilder};
-
-pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
-    let attrs = tcx.hir().attrs(id);
-    attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
-}
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 86f82c1304c..c28631b9825 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -8,7 +8,7 @@ use crate::hir::map as hir_map;
 use crate::hir::map::DefPathHash;
 use crate::ich::{NodeIdHashingMode, StableHashingContext};
 use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
-use crate::lint::{maybe_lint_level_root, struct_lint_level, LintSource};
+use crate::lint::{struct_lint_level, LintSource};
 use crate::middle;
 use crate::middle::cstore::CrateStoreDyn;
 use crate::middle::cstore::EncodedMetadata;
@@ -2568,19 +2568,17 @@ impl<'tcx> TyCtxt<'tcx> {
 
     /// Walks upwards from `id` to find a node which might change lint levels with attributes.
     /// It stops at `bound` and just returns it if reached.
-    pub fn maybe_lint_level_root_bounded(
-        self,
-        mut id: hir::HirId,
-        bound: hir::HirId,
-    ) -> hir::HirId {
+    pub fn maybe_lint_level_root_bounded(self, mut id: HirId, bound: HirId) -> HirId {
+        let hir = self.hir();
         loop {
             if id == bound {
                 return bound;
             }
-            if maybe_lint_level_root(self, id) {
+
+            if hir.attrs(id).iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) {
                 return id;
             }
-            let next = self.hir().get_parent_node(id);
+            let next = hir.get_parent_node(id);
             if next == id {
                 bug!("lint traversal reached the root of the crate");
             }