Skip to content

Commit a4c0daa

Browse files
committed
Remove LegacyBindingKind::MacroUse.
1 parent 111caef commit a4c0daa

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

src/librustc_resolve/macros.rs

+15-34
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ impl<'a> LegacyScope<'a> {
7575

7676
pub struct LegacyBinding<'a> {
7777
parent: LegacyScope<'a>,
78-
kind: LegacyBindingKind,
79-
}
80-
81-
pub enum LegacyBindingKind {
82-
MacroRules(ast::Name, Rc<SyntaxExtension>, Span),
83-
MacroUse(LegacyImports),
78+
name: ast::Name,
79+
ext: Rc<SyntaxExtension>,
80+
span: Span,
8481
}
8582

8683
pub type LegacyImports = FnvHashMap<ast::Name, (Rc<SyntaxExtension>, Span)>;
@@ -123,10 +120,11 @@ impl<'a> base::Resolver for Resolver<'a> {
123120
}
124121
if def.use_locally {
125122
let invocation = self.invocations[&scope];
126-
let ext = Rc::new(macro_rules::compile(&self.session.parse_sess, &def));
127123
let binding = self.arenas.alloc_legacy_binding(LegacyBinding {
128124
parent: invocation.legacy_scope.get(),
129-
kind: LegacyBindingKind::MacroRules(def.ident.name, ext, def.span),
125+
name: def.ident.name,
126+
ext: Rc::new(macro_rules::compile(&self.session.parse_sess, &def)),
127+
span: def.span,
130128
});
131129
invocation.legacy_scope.set(LegacyScope::Binding(binding));
132130
self.macro_names.insert(def.ident.name);
@@ -208,12 +206,6 @@ impl<'a> Resolver<'a> {
208206
name: ast::Name,
209207
record_used: bool)
210208
-> Option<Rc<SyntaxExtension>> {
211-
let check_shadowing = |this: &mut Self, relative_depth, scope, span| {
212-
if record_used && relative_depth > 0 {
213-
this.disallowed_shadowing.push((name, span, scope));
214-
}
215-
};
216-
217209
let mut relative_depth: u32 = 0;
218210
loop {
219211
scope = match scope {
@@ -227,29 +219,18 @@ impl<'a> Resolver<'a> {
227219
}
228220
}
229221
LegacyScope::Invocation(invocation) => {
230-
let new_relative_depth = relative_depth.saturating_sub(1);
231-
let mut scope = invocation.legacy_scope.get();
232-
if let LegacyScope::Binding(binding) = scope {
233-
match binding.kind {
234-
LegacyBindingKind::MacroUse(ref imports) => {
235-
if let Some(&(ref ext, span)) = imports.get(&name) {
236-
check_shadowing(self, relative_depth, binding.parent, span);
237-
return Some(ext.clone());
238-
}
239-
},
240-
LegacyBindingKind::MacroRules(name_, ref ext, span) => {
241-
if name_ == name {
242-
check_shadowing(self, new_relative_depth, binding.parent, span);
243-
return Some(ext.clone());
244-
}
245-
}
222+
relative_depth = relative_depth.saturating_sub(1);
223+
invocation.legacy_scope.get()
224+
}
225+
LegacyScope::Binding(binding) => {
226+
if binding.name == name {
227+
if record_used && relative_depth > 0 {
228+
self.disallowed_shadowing.push((name, binding.span, binding.parent));
246229
}
247-
scope = binding.parent
230+
return Some(binding.ext.clone());
248231
}
249-
relative_depth = new_relative_depth;
250-
scope
232+
binding.parent
251233
}
252-
_ => unreachable!(),
253234
};
254235
}
255236

0 commit comments

Comments
 (0)