X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_resolve%2Fbuild_reduced_graph.rs;h=c782f2072b9aaaacaed4b844c11f4f0691a6e033;hb=aa1e6db70900cf5d11a843bc4234de0548677aba;hp=4553a2ab5779f6e972600ee119c72812f7c22ba2;hpb=14546cd5010b57735a76e1fa420405cb36092963;p=rust.git diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 4553a2ab577..c782f2072b9 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -21,10 +21,11 @@ use Namespace::{self, TypeNS, ValueNS, MacroNS}; use {resolve_error, resolve_struct_error, ResolutionError}; -use rustc::middle::cstore::LoadedMacro; use rustc::hir::def::*; use rustc::hir::def_id::{BUILTIN_MACROS_CRATE, CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; use rustc::ty; +use rustc::middle::cstore::CrateStore; +use rustc_metadata::cstore::LoadedMacro; use std::cell::Cell; use rustc_data_structures::sync::Lrc; @@ -86,7 +87,7 @@ struct LegacyMacroImports { imports: Vec<(Name, Span)>, } -impl<'a> Resolver<'a> { +impl<'a, 'cl> Resolver<'a, 'cl> { /// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined; /// otherwise, reports an error. pub fn define(&mut self, parent: Module<'a>, ident: Ident, ns: Namespace, def: T) @@ -629,7 +630,8 @@ pub fn macro_def_scope(&mut self, expansion: Mark) -> Module<'a> { pub fn get_macro(&mut self, def: Def) -> Lrc { let def_id = match def { Def::Macro(def_id, ..) => def_id, - _ => panic!("Expected Def::Macro(..)"), + Def::NonMacroAttr => return Lrc::new(SyntaxExtension::NonMacroAttr), + _ => panic!("Expected Def::Macro(..) or Def::NonMacroAttr"), }; if let Some(ext) = self.macro_map.get(&def_id) { return ext.clone(); @@ -775,13 +777,13 @@ fn legacy_macro_imports(&mut self, attrs: &[ast::Attribute]) -> LegacyMacroImpor } } -pub struct BuildReducedGraphVisitor<'a, 'b: 'a> { - pub resolver: &'a mut Resolver<'b>, +pub struct BuildReducedGraphVisitor<'a, 'b: 'a, 'c: 'b> { + pub resolver: &'a mut Resolver<'b, 'c>, pub legacy_scope: LegacyScope<'b>, pub expansion: Mark, } -impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { +impl<'a, 'b, 'cl> BuildReducedGraphVisitor<'a, 'b, 'cl> { fn visit_invoc(&mut self, id: ast::NodeId) -> &'b InvocationData<'b> { let mark = id.placeholder_to_mark(); self.resolver.current_module.unresolved_invocations.borrow_mut().insert(mark); @@ -805,7 +807,7 @@ fn $visit(&mut self, node: &'a $ty) { } } -impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> { +impl<'a, 'b, 'cl> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b, 'cl> { method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item); method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr); method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat);