@@ -17,7 +17,8 @@ use rustc_middle::dep_graph::DepGraph;
17
17
use rustc_middle:: ty:: { GlobalCtxt , TyCtxt } ;
18
18
use rustc_session:: config:: { self , CrateType , OutputFilenames , OutputType } ;
19
19
use rustc_session:: cstore:: Untracked ;
20
- use rustc_session:: { output:: find_crate_name, Session } ;
20
+ use rustc_session:: output:: find_crate_name;
21
+ use rustc_session:: Session ;
21
22
use rustc_span:: symbol:: sym;
22
23
use std:: any:: Any ;
23
24
use std:: cell:: { RefCell , RefMut } ;
@@ -101,25 +102,18 @@ impl<'tcx> Queries<'tcx> {
101
102
}
102
103
}
103
104
104
- fn session ( & self ) -> & Session {
105
- self . compiler . session ( )
106
- }
107
-
108
- fn codegen_backend ( & self ) -> & dyn CodegenBackend {
109
- self . compiler . codegen_backend ( )
110
- }
111
-
112
105
pub fn parse ( & self ) -> Result < QueryResult < ' _ , ast:: Crate > > {
113
- self . parse
114
- . compute ( || passes:: parse ( self . session ( ) ) . map_err ( |mut parse_error| parse_error. emit ( ) ) )
106
+ self . parse . compute ( || {
107
+ passes:: parse ( & self . compiler . sess ) . map_err ( |mut parse_error| parse_error. emit ( ) )
108
+ } )
115
109
}
116
110
117
111
#[ deprecated = "pre_configure may be made private in the future. If you need it please open an issue with your use case." ]
118
112
pub fn pre_configure ( & self ) -> Result < QueryResult < ' _ , ( ast:: Crate , ast:: AttrVec ) > > {
119
113
self . pre_configure . compute ( || {
120
114
let mut krate = self . parse ( ) ?. steal ( ) ;
121
115
122
- let sess = self . session ( ) ;
116
+ let sess = & self . compiler . sess ;
123
117
rustc_builtin_macros:: cmdline_attrs:: inject (
124
118
& mut krate,
125
119
& sess. parse_sess ,
@@ -134,7 +128,7 @@ impl<'tcx> Queries<'tcx> {
134
128
135
129
pub fn global_ctxt ( & ' tcx self ) -> Result < QueryResult < ' _ , & ' tcx GlobalCtxt < ' tcx > > > {
136
130
self . gcx . compute ( || {
137
- let sess = self . session ( ) ;
131
+ let sess = & self . compiler . sess ;
138
132
#[ allow( deprecated) ]
139
133
let ( krate, pre_configured_attrs) = self . pre_configure ( ) ?. steal ( ) ;
140
134
@@ -150,7 +144,7 @@ impl<'tcx> Queries<'tcx> {
150
144
let dep_graph = setup_dep_graph ( sess, crate_name, stable_crate_id) ?;
151
145
152
146
let cstore = FreezeLock :: new ( Box :: new ( CStore :: new (
153
- self . codegen_backend ( ) . metadata_loader ( ) ,
147
+ self . compiler . codegen_backend . metadata_loader ( ) ,
154
148
stable_crate_id,
155
149
) ) as _ ) ;
156
150
let definitions = FreezeLock :: new ( Definitions :: new ( stable_crate_id) ) ;
@@ -189,16 +183,16 @@ impl<'tcx> Queries<'tcx> {
189
183
pub fn ongoing_codegen ( & ' tcx self ) -> Result < Box < dyn Any > > {
190
184
self . global_ctxt ( ) ?. enter ( |tcx| {
191
185
// Don't do code generation if there were any errors
192
- self . session ( ) . compile_status ( ) ?;
186
+ self . compiler . sess . compile_status ( ) ?;
193
187
194
188
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
195
189
// it's likely that codegen will only cause more ICEs, obscuring the original problem
196
- self . session ( ) . diagnostic ( ) . flush_delayed ( ) ;
190
+ self . compiler . sess . diagnostic ( ) . flush_delayed ( ) ;
197
191
198
192
// Hook for UI tests.
199
193
Self :: check_for_rustc_errors_attr ( tcx) ;
200
194
201
- Ok ( passes:: start_codegen ( self . codegen_backend ( ) , tcx) )
195
+ Ok ( passes:: start_codegen ( & * self . compiler . codegen_backend , tcx) )
202
196
} )
203
197
}
204
198
@@ -317,17 +311,16 @@ impl Compiler {
317
311
// after this point, they'll show up as "<unknown>" in self-profiling data.
318
312
{
319
313
let _prof_timer =
320
- queries. session ( ) . prof . generic_activity ( "self_profile_alloc_query_strings" ) ;
314
+ queries. compiler . sess . prof . generic_activity ( "self_profile_alloc_query_strings" ) ;
321
315
gcx. enter ( rustc_query_impl:: alloc_self_profile_query_strings) ;
322
316
}
323
317
324
- self . session ( )
325
- . time ( "serialize_dep_graph" , || gcx. enter ( rustc_incremental:: save_dep_graph) ) ;
318
+ self . sess . time ( "serialize_dep_graph" , || gcx. enter ( rustc_incremental:: save_dep_graph) ) ;
326
319
}
327
320
328
321
// The timer's lifetime spans the dropping of `queries`, which contains
329
322
// the global context.
330
- _timer = Some ( self . session ( ) . timer ( "free_global_ctxt" ) ) ;
323
+ _timer = Some ( self . sess . timer ( "free_global_ctxt" ) ) ;
331
324
332
325
ret
333
326
}
0 commit comments