X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fhir%2Fmap%2Fmod.rs;h=eb6aded9cb3bd9dcf1050097467d433c64711044;hb=578da998afd116be69fe4e518a6279dcb18321d7;hp=598e28c1a3ab00ac9442f021aeb8aaadb07b512f;hpb=5af144ece1f454510fea4d521f0a9a26e4c33612;p=rust.git diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 598e28c1a3a..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), } } @@ -379,7 +379,7 @@ pub fn body_owned_by(&self, id: HirId) -> BodyId { pub fn body_param_names(&self, id: BodyId) -> impl Iterator + 'hir { self.body(id).params.iter().map(|arg| match arg.pat.kind { PatKind::Binding(_, _, ident, _) => ident, - _ => Ident::new(kw::Invalid, rustc_span::DUMMY_SP), + _ => Ident::new(kw::Empty, rustc_span::DUMMY_SP), }) } @@ -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 {