@@ -14,27 +14,22 @@ use rustc::session::{CrateDisambiguator, Session};
14
14
use rustc:: ty:: query:: Providers ;
15
15
use rustc:: ty:: query:: QueryConfig ;
16
16
use 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 ;
17
22
use rustc_data_structures:: svh:: Svh ;
18
23
use rustc_hir as hir;
19
24
use 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 ;
22
27
23
28
use rustc_data_structures:: sync:: Lrc ;
24
29
use smallvec:: SmallVec ;
25
30
use std:: any:: Any ;
26
31
use std:: sync:: Arc ;
27
32
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
-
38
33
macro_rules! provide {
39
34
( <$lt: tt> $tcx: ident, $def_id: ident, $other: ident, $cdata: ident,
40
35
$( $name: ident => $compute: block) * ) => {
@@ -419,15 +414,9 @@ impl CStore {
419
414
return LoadedMacro :: ProcMacro ( data. load_proc_macro ( id. index , sess) ) ;
420
415
}
421
416
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) ;
431
420
432
421
// Mark the attrs as used
433
422
let attrs = data. get_item_attrs ( id. index , sess) ;
@@ -441,22 +430,20 @@ impl CStore {
441
430
. data
442
431
. get_opt_name ( )
443
432
. 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) ) ;
447
434
448
435
LoadedMacro :: MacroDef (
449
436
ast:: Item {
450
437
// FIXME: cross-crate hygiene
451
438
ident : ast:: Ident :: with_dummy_span ( name) ,
452
439
id : ast:: DUMMY_NODE_ID ,
453
- span : local_span ,
440
+ span,
454
441
attrs : attrs. iter ( ) . cloned ( ) . collect ( ) ,
455
442
kind : ast:: ItemKind :: MacroDef ( ast:: MacroDef {
456
443
body : P ( ast:: MacArgs :: Delimited ( dspan, ast:: MacDelimiter :: Brace , body) ) ,
457
- legacy : def . legacy ,
444
+ legacy,
458
445
} ) ,
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 ) ,
460
447
tokens : None ,
461
448
} ,
462
449
data. root . edition ,
0 commit comments