Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3646bc2

Browse files
committedAug 25, 2021
Merge branch '9dce366ee25b279a7f4c81f5194d259f6b53d555'
2 parents a992a11 + 9dce366 commit 3646bc2

File tree

42 files changed

+282
-378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+282
-378
lines changed
 

‎compiler/rustc_ast_lowering/src/item.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
170170
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
171171
vec
172172
}
173-
ItemKind::MacroDef(..) => SmallVec::new(),
174173
ItemKind::Fn(..) | ItemKind::Impl(box ImplKind { of_trait: None, .. }) => {
175174
smallvec![i.id]
176175
}
@@ -212,28 +211,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
212211
pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item<'hir>> {
213212
let mut ident = i.ident;
214213
let mut vis = self.lower_visibility(&i.vis, None);
215-
216-
if let ItemKind::MacroDef(MacroDef { ref body, macro_rules }) = i.kind {
217-
if !macro_rules || self.sess.contains_name(&i.attrs, sym::macro_export) {
218-
let hir_id = self.lower_node_id(i.id);
219-
self.lower_attrs(hir_id, &i.attrs);
220-
let body = P(self.lower_mac_args(body));
221-
self.insert_macro_def(hir::MacroDef {
222-
ident,
223-
vis,
224-
def_id: hir_id.expect_owner(),
225-
span: i.span,
226-
ast: MacroDef { body, macro_rules },
227-
});
228-
} else {
229-
for a in i.attrs.iter() {
230-
let a = self.lower_attr(a);
231-
self.non_exported_macro_attrs.push(a);
232-
}
233-
}
234-
return None;
235-
}
236-
237214
let hir_id = self.lower_node_id(i.id);
238215
let attrs = self.lower_attrs(hir_id, &i.attrs);
239216
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, &mut vis, &i.kind);
@@ -465,7 +442,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
465442
self.lower_generics(generics, ImplTraitContext::disallowed()),
466443
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
467444
),
468-
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
445+
ItemKind::MacroDef(MacroDef { ref body, macro_rules }) => {
446+
let body = P(self.lower_mac_args(body));
447+
448+
hir::ItemKind::Macro(ast::MacroDef { body, macro_rules })
449+
}
450+
ItemKind::MacCall(..) => {
469451
panic!("`TyMac` should have been expanded by now")
470452
}
471453
}

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ struct LoweringContext<'a, 'hir: 'a> {
103103
/// The items being lowered are collected here.
104104
owners: IndexVec<LocalDefId, Option<hir::OwnerNode<'hir>>>,
105105
bodies: BTreeMap<hir::BodyId, hir::Body<'hir>>,
106-
non_exported_macro_attrs: Vec<ast::Attribute>,
107106

108107
trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
109108

@@ -330,7 +329,6 @@ pub fn lower_crate<'a, 'hir>(
330329
trait_impls: BTreeMap::new(),
331330
modules: BTreeMap::new(),
332331
attrs: BTreeMap::default(),
333-
non_exported_macro_attrs: Vec::new(),
334332
catch_scopes: Vec::new(),
335333
loop_scopes: Vec::new(),
336334
is_in_loop_condition: false,
@@ -551,7 +549,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
551549
}
552550

553551
let krate = hir::Crate {
554-
non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs),
555552
owners: self.owners,
556553
bodies: self.bodies,
557554
body_ids,
@@ -600,13 +597,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
600597
id
601598
}
602599

603-
fn insert_macro_def(&mut self, item: hir::MacroDef<'hir>) {
604-
let def_id = item.def_id;
605-
let item = self.arena.alloc(item);
606-
self.owners.ensure_contains_elem(def_id, || None);
607-
self.owners[def_id] = Some(hir::OwnerNode::MacroDef(item));
608-
}
609-
610600
fn allocate_hir_id_counter(&mut self, owner: NodeId) -> hir::HirId {
611601
// Set up the counter if needed.
612602
self.item_local_id_counters.entry(owner).or_insert(0);

0 commit comments

Comments
 (0)
Please sign in to comment.