Skip to content

Commit 16bf278

Browse files
committed
inline maybe_lint_level_root
1 parent eee84fe commit 16bf278

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/librustc/lint/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
pub use self::levels::LintSource::{self, *};
2222
pub use self::Level::*;
2323

24-
use crate::ty::TyCtxt;
2524
use rustc_data_structures::sync;
2625
use rustc_hir as hir;
2726
use rustc_session::lint::builtin::HardwiredLints;
@@ -315,8 +314,3 @@ pub mod internal;
315314
mod levels;
316315

317316
pub use self::levels::{struct_lint_level, LintLevelMap, LintLevelSets, LintLevelsBuilder};
318-
319-
pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
320-
let attrs = tcx.hir().attrs(id);
321-
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
322-
}

src/librustc/ty/context.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::hir::map as hir_map;
88
use crate::hir::map::DefPathHash;
99
use crate::ich::{NodeIdHashingMode, StableHashingContext};
1010
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
11-
use crate::lint::{maybe_lint_level_root, struct_lint_level, LintSource};
11+
use crate::lint::{struct_lint_level, LintSource};
1212
use crate::middle;
1313
use crate::middle::cstore::CrateStoreDyn;
1414
use crate::middle::cstore::EncodedMetadata;
@@ -2568,19 +2568,17 @@ impl<'tcx> TyCtxt<'tcx> {
25682568

25692569
/// Walks upwards from `id` to find a node which might change lint levels with attributes.
25702570
/// It stops at `bound` and just returns it if reached.
2571-
pub fn maybe_lint_level_root_bounded(
2572-
self,
2573-
mut id: hir::HirId,
2574-
bound: hir::HirId,
2575-
) -> hir::HirId {
2571+
pub fn maybe_lint_level_root_bounded(self, mut id: HirId, bound: HirId) -> HirId {
2572+
let hir = self.hir();
25762573
loop {
25772574
if id == bound {
25782575
return bound;
25792576
}
2580-
if maybe_lint_level_root(self, id) {
2577+
2578+
if hir.attrs(id).iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) {
25812579
return id;
25822580
}
2583-
let next = self.hir().get_parent_node(id);
2581+
let next = hir.get_parent_node(id);
25842582
if next == id {
25852583
bug!("lint traversal reached the root of the crate");
25862584
}

0 commit comments

Comments
 (0)