X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fhir%2Fmap%2Fmod.rs;h=eb6aded9cb3bd9dcf1050097467d433c64711044;hb=578da998afd116be69fe4e518a6279dcb18321d7;hp=09d5b102103120aebae9b7084e1aaf7f5c055547;hpb=a6bd5246da7806786b5c1f61d05a957c9ae68903;p=rust.git diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 09d5b102103..eb6aded9cb3 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -31,7 +31,7 @@ pub struct Entry<'hir> { impl<'hir> Entry<'hir> { fn parent_node(self) -> Option { match self.node { - Node::Crate(_) | Node::MacroDef(_) => None, + Node::Crate(_) => None, _ => Some(self.parent), } } @@ -710,15 +710,10 @@ pub fn get_defining_scope(&self, id: HirId) -> HirId { let mut scope = id; loop { scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID); - if scope == CRATE_HIR_ID { - return CRATE_HIR_ID; - } - match self.get(scope) { - Node::Block(_) => {} - _ => break, + if scope == CRATE_HIR_ID || !matches!(self.get(scope), Node::Block(_)) { + return scope; } } - scope } pub fn get_parent_did(&self, id: HirId) -> LocalDefId {