diff options
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/build/scope.rs | 27 |
2 files changed, 24 insertions, 23 deletions
diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 81c1ae4f630..20230217afc 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -169,26 +169,6 @@ impl TyCtxt<'_> { pub fn lint_level_at_node(self, lint: &'static Lint, id: HirId) -> (Level, LintLevelSource) { self.shallow_lint_levels_on(id.owner).lint_level_id_at_node(self, LintId::of(lint), id) } - - /// 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: HirId, bound: HirId) -> HirId { - let hir = self.hir(); - loop { - if id == bound { - return bound; - } - - if hir.attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) { - return id; - } - let next = hir.parent_id(id); - if next == id { - bug!("lint traversal reached the root of the crate"); - } - id = next; - } - } } /// This struct represents a lint expectation and holds all required information diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 5bbf3347837..d7953d0c4af 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -90,8 +90,8 @@ use rustc_index::{IndexSlice, IndexVec}; use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_middle::thir::{Expr, LintLevel}; - use rustc_middle::ty::Ty; +use rustc_session::lint::Level; use rustc_span::{Span, DUMMY_SP}; #[derive(Debug)] @@ -773,8 +773,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // to avoid adding Hir dependencies on our parents. // We estimate the true lint roots here to avoid creating a lot of source scopes. ( - self.tcx.maybe_lint_level_root_bounded(current_id, self.hir_id), - self.tcx.maybe_lint_level_root_bounded(parent_id, self.hir_id), + self.maybe_lint_level_root_bounded(current_id, self.hir_id), + self.maybe_lint_level_root_bounded(parent_id, self.hir_id), ) }; @@ -784,6 +784,27 @@ impl<'a, 'tcx> Builder<'a, '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. + fn maybe_lint_level_root_bounded(&self, mut id: HirId, bound: HirId) -> HirId { + let hir = self.tcx.hir(); + loop { + if id == bound { + return bound; + } + + if hir.attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) { + return id; + } + + let next = hir.parent_id(id); + if next == id { + bug!("lint traversal reached the root of the crate"); + } + id = next; + } + } + /// Creates a new source scope, nested in the current one. pub(crate) fn new_source_scope( &mut self, |
