Skip to content
Permalink
Browse files

inline maybe_lint_level_root

  • Loading branch information
Centril committed Jan 9, 2020
1 parent eee84fe commit 16bf2783b5cd5f0a6155094f885890f4c0834477
Showing with 6 additions and 14 deletions.
  1. +0 −6 src/librustc/lint/mod.rs
  2. +6 −8 src/librustc/ty/context.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())
}
@@ -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");
}

0 comments on commit 16bf278

Please sign in to comment.
You can’t perform that action at this time.