Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process #[macro_use] imports in resolve and clean up macro loading #37292

Merged
merged 5 commits into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ impl<'a> LoweringContext<'a> {
id: m.id,
span: m.span,
imported_from: m.imported_from.map(|x| x.name),
export: m.export,
use_locally: m.use_locally,
allow_internal_unstable: m.allow_internal_unstable,
body: m.body.clone().into(),
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@ pub struct MacroDef {
pub id: NodeId,
pub span: Span,
pub imported_from: Option<Name>,
pub export: bool,
pub use_locally: bool,
pub allow_internal_unstable: bool,
pub body: HirVec<TokenTree>,
}
Expand Down
22 changes: 13 additions & 9 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use util::nodemap::{NodeSet, DefIdMap};
use std::path::PathBuf;
use syntax::ast;
use syntax::attr;
use syntax::ext::base::MultiItemModifier;
use syntax::ext::base::SyntaxExtension;
use syntax::ptr::P;
use syntax::parse::token::InternedString;
use syntax_pos::Span;
Expand Down Expand Up @@ -417,18 +417,22 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
}

pub struct LoadedMacro {
pub import_site: Span,
pub kind: LoadedMacroKind,
pub enum LoadedMacros {
MacroRules(Vec<ast::MacroDef>),
ProcMacros(Vec<(ast::Name, SyntaxExtension)>),
}

pub enum LoadedMacroKind {
Def(ast::MacroDef),
CustomDerive(String, Box<MultiItemModifier>),
impl LoadedMacros {
pub fn is_proc_macros(&self) -> bool {
match *self {
LoadedMacros::ProcMacros(_) => true,
_ => false,
}
}
}

pub trait CrateLoader {
fn load_macros(&mut self, extern_crate: &ast::Item, allows_macros: bool) -> Vec<LoadedMacro>;
fn process_item(&mut self, item: &ast::Item, defs: &Definitions);
fn process_item(&mut self, item: &ast::Item, defs: &Definitions, load_macros: bool)
-> Option<LoadedMacros>;
fn postprocess(&mut self, krate: &ast::Crate);
}
12 changes: 5 additions & 7 deletions src/librustc_incremental/calculate_svh/svh_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,11 @@ impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'has

fn visit_macro_def(&mut self, macro_def: &'tcx MacroDef) {
debug!("visit_macro_def: st={:?}", self.st);
if macro_def.export {
SawMacroDef.hash(self.st);
hash_attrs!(self, &macro_def.attrs);
visit::walk_macro_def(self, macro_def)
// FIXME(mw): We should hash the body of the macro too but we don't
// have a stable way of doing so yet.
}
SawMacroDef.hash(self.st);
hash_attrs!(self, &macro_def.attrs);
visit::walk_macro_def(self, macro_def)
// FIXME(mw): We should hash the body of the macro too but we don't
// have a stable way of doing so yet.
}
}

Expand Down
Loading