From d82a7bc1b5615548811d2c50cc64f6d486ef1d02 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 22 Feb 2022 09:37:47 -0300 Subject: [PATCH] local_id is always != 0 at this point --- compiler/rustc_ast_lowering/src/lib.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 4254c2d06b2..3e6dfc24f3b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -549,19 +549,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { v.insert(local_id); self.item_local_id_counter.increment_by(1); - if local_id != hir::ItemLocalId::new(0) { - if let Some(def_id) = self.resolver.opt_local_def_id(ast_node_id) { - self.owners.ensure_contains_elem(def_id, || hir::MaybeOwner::Phantom); - if let o @ hir::MaybeOwner::Phantom = &mut self.owners[def_id] { - // Do not override a `MaybeOwner::Owner` that may already here. - *o = hir::MaybeOwner::NonOwner(hir_id); - } - self.local_id_to_def_id.insert(local_id, def_id); + assert_ne!(local_id, hir::ItemLocalId::new(0)); + if let Some(def_id) = self.resolver.opt_local_def_id(ast_node_id) { + self.owners.ensure_contains_elem(def_id, || hir::MaybeOwner::Phantom); + if let o @ hir::MaybeOwner::Phantom = &mut self.owners[def_id] { + // Do not override a `MaybeOwner::Owner` that may already here. + *o = hir::MaybeOwner::NonOwner(hir_id); } + self.local_id_to_def_id.insert(local_id, def_id); + } - if let Some(traits) = self.resolver.take_trait_map(ast_node_id) { - self.trait_map.insert(hir_id.local_id, traits.into_boxed_slice()); - } + if let Some(traits) = self.resolver.take_trait_map(ast_node_id) { + self.trait_map.insert(hir_id.local_id, traits.into_boxed_slice()); } hir_id