mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-10 19:16:51 +00:00
inline maybe_lint_level_root
This commit is contained in:
parent
eee84fe396
commit
16bf2783b5
@ -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())
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user