@@ -14,27 +14,22 @@ use rustc::session::{CrateDisambiguator, Session};
1414use rustc:: ty:: query:: Providers ;
1515use rustc:: ty:: query:: QueryConfig ;
1616use rustc:: ty:: { self , TyCtxt } ;
17+ use rustc_ast:: ast;
18+ use rustc_ast:: attr;
19+ use rustc_ast:: expand:: allocator:: AllocatorKind ;
20+ use rustc_ast:: ptr:: P ;
21+ use rustc_ast:: tokenstream:: DelimSpan ;
1722use rustc_data_structures:: svh:: Svh ;
1823use rustc_hir as hir;
1924use rustc_hir:: def_id:: { CrateNum , DefId , DefIdMap , CRATE_DEF_INDEX , LOCAL_CRATE } ;
20- use rustc_parse :: parser :: emit_unclosed_delims ;
21- use rustc_parse :: source_file_to_stream ;
25+ use rustc_span :: source_map :: { self , Span , Spanned } ;
26+ use rustc_span :: symbol :: Symbol ;
2227
2328use rustc_data_structures:: sync:: Lrc ;
2429use smallvec:: SmallVec ;
2530use std:: any:: Any ;
2631use std:: sync:: Arc ;
2732
28- use rustc_ast:: ast;
29- use rustc_ast:: attr;
30- use rustc_ast:: expand:: allocator:: AllocatorKind ;
31- use rustc_ast:: ptr:: P ;
32- use rustc_ast:: tokenstream:: DelimSpan ;
33- use rustc_span:: source_map;
34- use rustc_span:: source_map:: Spanned ;
35- use rustc_span:: symbol:: Symbol ;
36- use rustc_span:: { FileName , Span } ;
37-
3833macro_rules! provide {
3934 ( <$lt: tt> $tcx: ident, $def_id: ident, $other: ident, $cdata: ident,
4035 $( $name: ident => $compute: block) * ) => {
@@ -419,15 +414,9 @@ impl CStore {
419414 return LoadedMacro :: ProcMacro ( data. load_proc_macro ( id. index , sess) ) ;
420415 }
421416
422- let def = data. get_macro ( id. index ) ;
423- let macro_full_name = data. def_path ( id. index ) . to_string_friendly ( |_| data. root . name ) ;
424- let source_name = FileName :: Macros ( macro_full_name) ;
425-
426- let source_file = sess. parse_sess . source_map ( ) . new_source_file ( source_name, def. body ) ;
427- let local_span = Span :: with_root_ctxt ( source_file. start_pos , source_file. end_pos ) ;
428- let dspan = DelimSpan :: from_single ( local_span) ;
429- let ( body, mut errors) = source_file_to_stream ( & sess. parse_sess , source_file, None ) ;
430- emit_unclosed_delims ( & mut errors, & sess. parse_sess ) ;
417+ let span = data. get_span ( id. index , sess) ;
418+ let dspan = DelimSpan :: from_single ( span) ;
419+ let rmeta:: MacroDef { body, legacy } = data. get_macro ( id. index , sess) ;
431420
432421 // Mark the attrs as used
433422 let attrs = data. get_item_attrs ( id. index , sess) ;
@@ -441,22 +430,20 @@ impl CStore {
441430 . data
442431 . get_opt_name ( )
443432 . expect ( "no name in load_macro" ) ;
444- sess. imported_macro_spans
445- . borrow_mut ( )
446- . insert ( local_span, ( name. to_string ( ) , data. get_span ( id. index , sess) ) ) ;
433+ sess. imported_macro_spans . borrow_mut ( ) . insert ( span, ( name. to_string ( ) , span) ) ;
447434
448435 LoadedMacro :: MacroDef (
449436 ast:: Item {
450437 // FIXME: cross-crate hygiene
451438 ident : ast:: Ident :: with_dummy_span ( name) ,
452439 id : ast:: DUMMY_NODE_ID ,
453- span : local_span ,
440+ span,
454441 attrs : attrs. iter ( ) . cloned ( ) . collect ( ) ,
455442 kind : ast:: ItemKind :: MacroDef ( ast:: MacroDef {
456443 body : P ( ast:: MacArgs :: Delimited ( dspan, ast:: MacDelimiter :: Brace , body) ) ,
457- legacy : def . legacy ,
444+ legacy,
458445 } ) ,
459- vis : source_map:: respan ( local_span . shrink_to_lo ( ) , ast:: VisibilityKind :: Inherited ) ,
446+ vis : source_map:: respan ( span . shrink_to_lo ( ) , ast:: VisibilityKind :: Inherited ) ,
460447 tokens : None ,
461448 } ,
462449 data. root . edition ,
0 commit comments