@@ -99,7 +99,7 @@ pub fn compile_input(sess: &Session,
99
99
}
100
100
} ;
101
101
102
- let krate = {
102
+ let ( krate, registry ) = {
103
103
let mut compile_state = CompileState :: state_after_parse ( input,
104
104
sess,
105
105
outdir,
@@ -111,14 +111,14 @@ pub fn compile_input(sess: &Session,
111
111
compile_state,
112
112
Ok ( ( ) ) ) ;
113
113
114
- compile_state. krate . unwrap ( )
114
+ ( compile_state. krate . unwrap ( ) , compile_state . registry )
115
115
} ;
116
116
117
117
let outputs = build_output_filenames ( input, outdir, output, & krate. attrs , sess) ;
118
118
let crate_name = link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
119
119
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
120
120
phase_2_configure_and_expand (
121
- sess, & cstore, krate, & crate_name, addl_plugins, control. make_glob_map ,
121
+ sess, & cstore, krate, registry , & crate_name, addl_plugins, control. make_glob_map ,
122
122
|expanded_crate| {
123
123
let mut state = CompileState :: state_after_expand (
124
124
input, sess, outdir, output, & cstore, expanded_crate, & crate_name,
@@ -332,6 +332,7 @@ pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
332
332
pub input : & ' a Input ,
333
333
pub session : & ' ast Session ,
334
334
pub krate : Option < ast:: Crate > ,
335
+ pub registry : Option < Registry < ' a > > ,
335
336
pub cstore : Option < & ' a CStore > ,
336
337
pub crate_name : Option < & ' a str > ,
337
338
pub output_filenames : Option < & ' a OutputFilenames > ,
@@ -360,6 +361,7 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
360
361
out_file : None ,
361
362
arenas : None ,
362
363
krate : None ,
364
+ registry : None ,
363
365
cstore : None ,
364
366
crate_name : None ,
365
367
output_filenames : None ,
@@ -382,6 +384,8 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
382
384
cstore : & ' a CStore )
383
385
-> CompileState < ' a , ' b , ' ast , ' tcx > {
384
386
CompileState {
387
+ // Initialize the registry before moving `krate`
388
+ registry : Some ( Registry :: new ( & session, krate. span ) ) ,
385
389
krate : Some ( krate) ,
386
390
cstore : Some ( cstore) ,
387
391
out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
@@ -548,6 +552,7 @@ pub struct ExpansionResult<'a> {
548
552
pub fn phase_2_configure_and_expand < ' a , F > ( sess : & Session ,
549
553
cstore : & CStore ,
550
554
mut krate : ast:: Crate ,
555
+ registry : Option < Registry > ,
551
556
crate_name : & ' a str ,
552
557
addl_plugins : Option < Vec < String > > ,
553
558
make_glob_map : MakeGlobMap ,
@@ -595,7 +600,7 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
595
600
addl_plugins. take ( ) . unwrap ( ) )
596
601
} ) ;
597
602
598
- let mut registry = Registry :: new ( sess, & krate) ;
603
+ let mut registry = registry . unwrap_or ( Registry :: new ( sess, krate. span ) ) ;
599
604
600
605
time ( time_passes, "plugin registration" , || {
601
606
if sess. features . borrow ( ) . rustc_diagnostic_macros {
0 commit comments