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