diff options
| author | bors <bors@rust-lang.org> | 2025-04-01 07:21:28 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-01 07:21:28 +0000 | 
| commit | ed201574c5d6117fb4a491db545c96fa4289ea9c (patch) | |
| tree | 66e24caa2e6b2c690d60445ed035aaa003da63be /compiler/rustc_expand/src/expand.rs | |
| parent | 97ea17b71aba0badfe9c8295f57a434bf79bdb72 (diff) | |
| parent | ec10833609aa63327437aabfaedfbe8a0edcc4d9 (diff) | |
| download | rust-ed201574c5d6117fb4a491db545c96fa4289ea9c.tar.gz rust-ed201574c5d6117fb4a491db545c96fa4289ea9c.zip  | |
Auto merge of #138740 - nnethercote:ast-ItemKind-idents, r=fmease
Move `ast::Item::ident` into `ast::ItemKind` The follow-up to #138384, which did the same thing for `hir::ItemKind`. r? `@fmease`
Diffstat (limited to 'compiler/rustc_expand/src/expand.rs')
| -rw-r--r-- | compiler/rustc_expand/src/expand.rs | 13 | 
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 22da1179feb..bca846d2ec4 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -744,6 +744,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { item_inner.kind, ItemKind::Mod( _, + _, ModKind::Unloaded | ModKind::Loaded(_, Inline::No, _, _), ) ) => @@ -911,7 +912,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { impl<'ast, 'a> Visitor<'ast> for GateProcMacroInput<'a> { fn visit_item(&mut self, item: &'ast ast::Item) { match &item.kind { - ItemKind::Mod(_, mod_kind) + ItemKind::Mod(_, _, mod_kind) if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _, _)) => { feature_err( @@ -1221,9 +1222,8 @@ impl InvocationCollectorNode for P<ast::Item> { } // Work around borrow checker not seeing through `P`'s deref. - let (ident, span, mut attrs) = (node.ident, node.span, mem::take(&mut node.attrs)); - let ItemKind::Mod(_, mod_kind) = &mut node.kind else { unreachable!() }; - + let (span, mut attrs) = (node.span, mem::take(&mut node.attrs)); + let ItemKind::Mod(_, ident, ref mut mod_kind) = node.kind else { unreachable!() }; let ecx = &mut collector.cx; let (file_path, dir_path, dir_ownership) = match mod_kind { ModKind::Loaded(_, inline, _, _) => { @@ -1305,6 +1305,7 @@ impl InvocationCollectorNode for P<ast::Item> { collector.cx.current_expansion.module = orig_module; res } + fn declared_names(&self) -> Vec<Ident> { if let ItemKind::Use(ut) = &self.kind { fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) { @@ -1324,7 +1325,7 @@ impl InvocationCollectorNode for P<ast::Item> { return idents; } - vec![self.ident] + if let Some(ident) = self.kind.ident() { vec![ident] } else { vec![] } } } @@ -1844,11 +1845,11 @@ fn build_single_delegations<'a, Node: InvocationCollectorNode>( id: ast::DUMMY_NODE_ID, span: if from_glob { item_span } else { ident.span }, vis: item.vis.clone(), - ident: rename.unwrap_or(ident), kind: Node::delegation_item_kind(Box::new(ast::Delegation { id: ast::DUMMY_NODE_ID, qself: deleg.qself.clone(), path, + ident: rename.unwrap_or(ident), rename, body: deleg.body.clone(), from_glob,  | 
