Skip to content

Commit e80d1a8

Browse files
committed
Remove MacroDef's fields imported_from and allow_internal_unstable,
remove `export` argument of `resolver.add_macro()`.
1 parent 4d638fd commit e80d1a8

File tree

11 files changed

+12
-27
lines changed

11 files changed

+12
-27
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate) {
365365
pub fn walk_macro_def<'v, V: Visitor<'v>>(visitor: &mut V, macro_def: &'v MacroDef) {
366366
visitor.visit_id(macro_def.id);
367367
visitor.visit_name(macro_def.span, macro_def.name);
368-
walk_opt_name(visitor, macro_def.span, macro_def.imported_from);
369368
walk_list!(visitor, visit_attribute, &macro_def.attrs);
370369
}
371370

src/librustc/hir/lowering.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,6 @@ impl<'a> LoweringContext<'a> {
987987
attrs: self.lower_attrs(&m.attrs),
988988
id: m.id,
989989
span: m.span,
990-
imported_from: m.imported_from.map(|x| x.name),
991-
allow_internal_unstable: m.allow_internal_unstable,
992990
body: m.body.clone().into(),
993991
}
994992
}

src/librustc/hir/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ pub struct MacroDef {
475475
pub attrs: HirVec<Attribute>,
476476
pub id: NodeId,
477477
pub span: Span,
478-
pub imported_from: Option<Name>,
479-
pub allow_internal_unstable: bool,
480478
pub body: HirVec<TokenTree>,
481479
}
482480

src/librustc/middle/stability.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
302302
}
303303

304304
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
305-
if md.imported_from.is_none() {
306-
self.annotate(md.id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
307-
}
305+
self.annotate(md.id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
308306
}
309307
}
310308

@@ -373,9 +371,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
373371
}
374372

375373
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
376-
if md.imported_from.is_none() {
377-
self.check_missing_stability(md.id, md.span);
378-
}
374+
self.check_missing_stability(md.id, md.span);
379375
}
380376
}
381377

src/librustc_metadata/cstore_impl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
418418
ident: ast::Ident::with_empty_ctxt(name),
419419
id: ast::DUMMY_NODE_ID,
420420
span: local_span,
421-
imported_from: None, // FIXME
422-
allow_internal_unstable: attr::contains_name(&attrs, "allow_internal_unstable"),
423421
attrs: attrs,
424422
body: body,
425423
})

src/librustc_resolve/macros.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc::ty;
2020
use std::cell::Cell;
2121
use std::rc::Rc;
2222
use syntax::ast::{self, Name, Ident};
23+
use syntax::attr;
2324
use syntax::errors::DiagnosticBuilder;
2425
use syntax::ext::base::{self, Determinacy, MultiModifier, MultiDecorator};
2526
use syntax::ext::base::{NormalTT, SyntaxExtension};
@@ -138,7 +139,7 @@ impl<'a> base::Resolver for Resolver<'a> {
138139
invocation.expansion.set(visitor.legacy_scope);
139140
}
140141

141-
fn add_macro(&mut self, scope: Mark, mut def: ast::MacroDef, export: bool) {
142+
fn add_macro(&mut self, scope: Mark, mut def: ast::MacroDef) {
142143
if def.ident.name == "macro_rules" {
143144
self.session.span_err(def.span, "user-defined macros may not be named `macro_rules`");
144145
}
@@ -153,7 +154,7 @@ impl<'a> base::Resolver for Resolver<'a> {
153154
invocation.legacy_scope.set(LegacyScope::Binding(binding));
154155
self.macro_names.insert(def.ident.name);
155156

156-
if export {
157+
if attr::contains_name(&def.attrs, "macro_export") {
157158
def.id = self.next_node_id();
158159
DefCollector::new(&mut self.definitions).with_parent(CRATE_DEF_INDEX, |collector| {
159160
collector.visit_macro_def(&def)

src/librustdoc/visit_ast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
201201
if def_id.krate == LOCAL_CRATE {
202202
continue // These are `krate.exported_macros`, handled in `self.visit()`.
203203
}
204+
let imported_from = self.cx.sess().cstore.original_crate_name(def_id.krate);
204205
let def = match self.cx.sess().cstore.load_macro(def_id, self.cx.sess()) {
205206
LoadedMacro::MacroRules(macro_rules) => macro_rules,
206207
// FIXME(jseyfried): document proc macro reexports
@@ -217,7 +218,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
217218
matchers: matchers,
218219
stab: self.stability(def.id),
219220
depr: self.deprecation(def.id),
220-
imported_from: def.imported_from.map(|ident| ident.name),
221+
imported_from: Some(imported_from),
221222
})
222223
}
223224
}
@@ -525,7 +526,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
525526
matchers: matchers,
526527
stab: self.stability(def.id),
527528
depr: self.deprecation(def.id),
528-
imported_from: def.imported_from,
529+
imported_from: None,
529530
}
530531
}
531532
}

src/libsyntax/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,8 +1972,6 @@ pub struct MacroDef {
19721972
pub attrs: Vec<Attribute>,
19731973
pub id: NodeId,
19741974
pub span: Span,
1975-
pub imported_from: Option<Ident>,
1976-
pub allow_internal_unstable: bool,
19771975
pub body: Vec<TokenTree>,
19781976
}
19791977

src/libsyntax/ext/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ pub trait Resolver {
520520
fn eliminate_crate_var(&mut self, item: P<ast::Item>) -> P<ast::Item>;
521521

522522
fn visit_expansion(&mut self, mark: Mark, expansion: &Expansion);
523-
fn add_macro(&mut self, scope: Mark, def: ast::MacroDef, export: bool);
523+
fn add_macro(&mut self, scope: Mark, def: ast::MacroDef);
524524
fn add_ext(&mut self, ident: ast::Ident, ext: Rc<SyntaxExtension>);
525525
fn add_expansions_at_stmt(&mut self, id: ast::NodeId, macros: Vec<Mark>);
526526

@@ -544,7 +544,7 @@ impl Resolver for DummyResolver {
544544
fn eliminate_crate_var(&mut self, item: P<ast::Item>) -> P<ast::Item> { item }
545545

546546
fn visit_expansion(&mut self, _invoc: Mark, _expansion: &Expansion) {}
547-
fn add_macro(&mut self, _scope: Mark, _def: ast::MacroDef, _export: bool) {}
547+
fn add_macro(&mut self, _scope: Mark, _def: ast::MacroDef) {}
548548
fn add_ext(&mut self, _ident: ast::Ident, _ext: Rc<SyntaxExtension>) {}
549549
fn add_expansions_at_stmt(&mut self, _id: ast::NodeId, _macros: Vec<Mark>) {}
550550

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,11 @@ impl IdentMacroExpander for MacroRulesExpander {
160160
tts: Vec<tokenstream::TokenTree>,
161161
attrs: Vec<ast::Attribute>)
162162
-> Box<MacResult> {
163-
let export = attr::contains_name(&attrs, "macro_export");
164163
let def = ast::MacroDef {
165164
ident: ident,
166165
id: ast::DUMMY_NODE_ID,
167166
span: span,
168-
imported_from: None,
169167
body: tts,
170-
allow_internal_unstable: attr::contains_name(&attrs, "allow_internal_unstable"),
171168
attrs: attrs,
172169
};
173170

@@ -178,7 +175,7 @@ impl IdentMacroExpander for MacroRulesExpander {
178175
MacEager::items(placeholders::macro_scope_placeholder().make_items())
179176
};
180177

181-
cx.resolver.add_macro(cx.current_expansion.mark, def, export);
178+
cx.resolver.add_macro(cx.current_expansion.mark, def);
182179
result
183180
}
184181
}
@@ -282,7 +279,7 @@ pub fn compile(sess: &ParseSess, def: &ast::MacroDef) -> SyntaxExtension {
282279
valid: valid,
283280
});
284281

285-
NormalTT(exp, Some(def.span), def.allow_internal_unstable)
282+
NormalTT(exp, Some(def.span), attr::contains_name(&def.attrs, "allow_internal_unstable"))
286283
}
287284

288285
fn check_lhs_nt_follows(sess: &ParseSess, lhs: &TokenTree) -> bool {

src/libsyntax/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
178178

179179
pub fn walk_macro_def<'a, V: Visitor<'a>>(visitor: &mut V, macro_def: &'a MacroDef) {
180180
visitor.visit_ident(macro_def.span, macro_def.ident);
181-
walk_opt_ident(visitor, macro_def.span, macro_def.imported_from);
182181
walk_list!(visitor, visit_attribute, &macro_def.attrs);
183182
}
184183

0 commit comments

Comments
 (0)