@@ -31,7 +31,7 @@ use rustc_trans::trans;
31
31
use rustc_typeck as typeck;
32
32
use rustc_privacy;
33
33
use rustc_front:: hir;
34
- use rustc_front:: lowering:: lower_crate;
34
+ use rustc_front:: lowering:: { lower_crate, LoweringContext } ;
35
35
use super :: Compilation ;
36
36
37
37
use serialize:: json;
@@ -112,9 +112,11 @@ pub fn compile_input(sess: Session,
112
112
113
113
let expanded_crate = assign_node_ids ( & sess, expanded_crate) ;
114
114
// Lower ast -> hir.
115
+ let foo = & 42 ;
116
+ let lcx = LoweringContext :: new ( foo) ;
115
117
let mut hir_forest = time ( sess. time_passes ( ) ,
116
118
"lowering ast -> hir" ,
117
- || hir_map:: Forest :: new ( lower_crate ( & expanded_crate) ) ) ;
119
+ || hir_map:: Forest :: new ( lower_crate ( & lcx , & expanded_crate) ) ) ;
118
120
let arenas = ty:: CtxtArenas :: new ( ) ;
119
121
let ast_map = make_map ( & sess, & mut hir_forest) ;
120
122
@@ -128,7 +130,8 @@ pub fn compile_input(sess: Session,
128
130
& ast_map,
129
131
& expanded_crate,
130
132
& ast_map. krate( ) ,
131
- & id[ ..] ) ) ;
133
+ & id[ ..] ,
134
+ & lcx) ) ;
132
135
133
136
time ( sess. time_passes ( ) , "attribute checking" , || {
134
137
front:: check_attr:: check_crate ( & sess, & expanded_crate) ;
@@ -152,7 +155,8 @@ pub fn compile_input(sess: Session,
152
155
& expanded_crate,
153
156
tcx. map . krate ( ) ,
154
157
& analysis,
155
- tcx) ;
158
+ tcx,
159
+ & lcx) ;
156
160
( control. after_analysis . callback ) ( state) ;
157
161
158
162
tcx. sess . abort_if_errors ( ) ;
@@ -278,6 +282,7 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> {
278
282
pub ast_map : Option < & ' a hir_map:: Map < ' ast > > ,
279
283
pub analysis : Option < & ' a ty:: CrateAnalysis > ,
280
284
pub tcx : Option < & ' a ty:: ctxt < ' tcx > > ,
285
+ pub lcx : Option < & ' a LoweringContext < ' tcx > > ,
281
286
pub trans : Option < & ' a trans:: CrateTranslation > ,
282
287
}
283
288
@@ -299,6 +304,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
299
304
ast_map : None ,
300
305
analysis : None ,
301
306
tcx : None ,
307
+ lcx : None ,
302
308
trans : None ,
303
309
}
304
310
}
@@ -333,13 +339,15 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
333
339
ast_map : & ' a hir_map:: Map < ' ast > ,
334
340
krate : & ' a ast:: Crate ,
335
341
hir_crate : & ' a hir:: Crate ,
336
- crate_name : & ' a str )
342
+ crate_name : & ' a str ,
343
+ lcx : & ' a LoweringContext < ' tcx > )
337
344
-> CompileState < ' a , ' ast , ' tcx > {
338
345
CompileState {
339
346
crate_name : Some ( crate_name) ,
340
347
ast_map : Some ( ast_map) ,
341
348
krate : Some ( krate) ,
342
349
hir_crate : Some ( hir_crate) ,
350
+ lcx : Some ( lcx) ,
343
351
.. CompileState :: empty ( input, session, out_dir)
344
352
}
345
353
}
@@ -350,13 +358,15 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
350
358
krate : & ' a ast:: Crate ,
351
359
hir_crate : & ' a hir:: Crate ,
352
360
analysis : & ' a ty:: CrateAnalysis ,
353
- tcx : & ' a ty:: ctxt < ' tcx > )
361
+ tcx : & ' a ty:: ctxt < ' tcx > ,
362
+ lcx : & ' a LoweringContext < ' tcx > )
354
363
-> CompileState < ' a , ' ast , ' tcx > {
355
364
CompileState {
356
365
analysis : Some ( analysis) ,
357
366
tcx : Some ( tcx) ,
358
367
krate : Some ( krate) ,
359
368
hir_crate : Some ( hir_crate) ,
369
+ lcx : Some ( lcx) ,
360
370
.. CompileState :: empty ( input, session, out_dir)
361
371
}
362
372
}
0 commit comments