@@ -17,7 +17,8 @@ use rustc_middle::dep_graph::DepGraph;
1717use rustc_middle:: ty:: { GlobalCtxt , TyCtxt } ;
1818use rustc_session:: config:: { self , CrateType , OutputFilenames , OutputType } ;
1919use 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 ;
2122use rustc_span:: symbol:: sym;
2223use std:: any:: Any ;
2324use std:: cell:: { RefCell , RefMut } ;
@@ -101,25 +102,18 @@ impl<'tcx> Queries<'tcx> {
101102 }
102103 }
103104
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-
112105 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+ } )
115109 }
116110
117111 #[ deprecated = "pre_configure may be made private in the future. If you need it please open an issue with your use case." ]
118112 pub fn pre_configure ( & self ) -> Result < QueryResult < ' _ , ( ast:: Crate , ast:: AttrVec ) > > {
119113 self . pre_configure . compute ( || {
120114 let mut krate = self . parse ( ) ?. steal ( ) ;
121115
122- let sess = self . session ( ) ;
116+ let sess = & self . compiler . sess ;
123117 rustc_builtin_macros:: cmdline_attrs:: inject (
124118 & mut krate,
125119 & sess. parse_sess ,
@@ -134,7 +128,7 @@ impl<'tcx> Queries<'tcx> {
134128
135129 pub fn global_ctxt ( & ' tcx self ) -> Result < QueryResult < ' _ , & ' tcx GlobalCtxt < ' tcx > > > {
136130 self . gcx . compute ( || {
137- let sess = self . session ( ) ;
131+ let sess = & self . compiler . sess ;
138132 #[ allow( deprecated) ]
139133 let ( krate, pre_configured_attrs) = self . pre_configure ( ) ?. steal ( ) ;
140134
@@ -150,7 +144,7 @@ impl<'tcx> Queries<'tcx> {
150144 let dep_graph = setup_dep_graph ( sess, crate_name, stable_crate_id) ?;
151145
152146 let cstore = FreezeLock :: new ( Box :: new ( CStore :: new (
153- self . codegen_backend ( ) . metadata_loader ( ) ,
147+ self . compiler . codegen_backend . metadata_loader ( ) ,
154148 stable_crate_id,
155149 ) ) as _ ) ;
156150 let definitions = FreezeLock :: new ( Definitions :: new ( stable_crate_id) ) ;
@@ -189,16 +183,16 @@ impl<'tcx> Queries<'tcx> {
189183 pub fn ongoing_codegen ( & ' tcx self ) -> Result < Box < dyn Any > > {
190184 self . global_ctxt ( ) ?. enter ( |tcx| {
191185 // Don't do code generation if there were any errors
192- self . session ( ) . compile_status ( ) ?;
186+ self . compiler . sess . compile_status ( ) ?;
193187
194188 // If we have any delayed bugs, for example because we created TyKind::Error earlier,
195189 // 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 ( ) ;
197191
198192 // Hook for UI tests.
199193 Self :: check_for_rustc_errors_attr ( tcx) ;
200194
201- Ok ( passes:: start_codegen ( self . codegen_backend ( ) , tcx) )
195+ Ok ( passes:: start_codegen ( & * self . compiler . codegen_backend , tcx) )
202196 } )
203197 }
204198
@@ -317,17 +311,16 @@ impl Compiler {
317311 // after this point, they'll show up as "<unknown>" in self-profiling data.
318312 {
319313 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" ) ;
321315 gcx. enter ( rustc_query_impl:: alloc_self_profile_query_strings) ;
322316 }
323317
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) ) ;
326319 }
327320
328321 // The timer's lifetime spans the dropping of `queries`, which contains
329322 // the global context.
330- _timer = Some ( self . session ( ) . timer ( "free_global_ctxt" ) ) ;
323+ _timer = Some ( self . sess . timer ( "free_global_ctxt" ) ) ;
331324
332325 ret
333326 }
0 commit comments