@@ -28,8 +28,8 @@ use std::io::{self, IsTerminal, Read, Write};
2828use  std:: panic:: { self ,  PanicHookInfo ,  catch_unwind} ; 
2929use  std:: path:: { Path ,  PathBuf } ; 
3030use  std:: process:: { self ,  Command ,  Stdio } ; 
31+ use  std:: sync:: OnceLock ; 
3132use  std:: sync:: atomic:: { AtomicBool ,  Ordering } ; 
32- use  std:: sync:: { Arc ,  OnceLock } ; 
3333use  std:: time:: { Instant ,  SystemTime } ; 
3434use  std:: { env,  str} ; 
3535
@@ -60,7 +60,6 @@ use rustc_session::lint::{Lint, LintId};
6060use  rustc_session:: output:: collect_crate_types; 
6161use  rustc_session:: { EarlyDiagCtxt ,  Session ,  config,  filesearch} ; 
6262use  rustc_span:: FileName ; 
63- use  rustc_span:: source_map:: FileLoader ; 
6463use  rustc_target:: json:: ToJson ; 
6564use  rustc_target:: spec:: { Target ,  TargetTuple } ; 
6665use  time:: OffsetDateTime ; 
@@ -208,84 +207,7 @@ pub fn diagnostics_registry() -> Registry {
208207} 
209208
210209/// This is the primary entry point for rustc. 
211- pub  struct  RunCompiler <' a> { 
212-     at_args:  & ' a [ String ] , 
213-     callbacks:  & ' a mut  ( dyn Callbacks  + Send ) , 
214-     file_loader:  Option <Box <dyn FileLoader  + Send  + Sync >>, 
215-     make_codegen_backend: 
216-         Option <Box <dyn FnOnce ( & config:: Options )  -> Box <dyn CodegenBackend > + Send >>, 
217-     using_internal_features:  Arc <std:: sync:: atomic:: AtomicBool >, 
218- } 
219- 
220- impl <' a> RunCompiler <' a> { 
221-     pub  fn  new( at_args:  & ' a [ String ] ,  callbacks:  & ' a mut  ( dyn Callbacks  + Send ) )  -> Self  { 
222-         Self  { 
223-             at_args, 
224-             callbacks, 
225-             file_loader:  None , 
226-             make_codegen_backend:  None , 
227-             using_internal_features:  Arc :: default ( ) , 
228-         } 
229-     } 
230- 
231-     /// Set a custom codegen backend. 
232- /// 
233- /// Has no uses within this repository, but is used by bjorn3 for "the 
234- /// hotswapping branch of cg_clif" for "setting the codegen backend from a 
235- /// custom driver where the custom codegen backend has arbitrary data." 
236- /// (See #102759.) 
237- pub  fn  set_make_codegen_backend( 
238-         & mut  self , 
239-         make_codegen_backend:  Option <
240-             Box <dyn FnOnce ( & config:: Options )  -> Box <dyn CodegenBackend > + Send >, 
241-         >, 
242-     )  -> & mut  Self  { 
243-         self . make_codegen_backend = make_codegen_backend; 
244-         self 
245-     } 
246- 
247-     /// Load files from sources other than the file system. 
248- /// 
249- /// Has no uses within this repository, but may be used in the future by 
250- /// bjorn3 for "hooking rust-analyzer's VFS into rustc at some point for 
251- /// running rustc without having to save". (See #102759.) 
252- pub  fn  set_file_loader( 
253-         & mut  self , 
254-         file_loader:  Option <Box <dyn FileLoader  + Send  + Sync >>, 
255-     )  -> & mut  Self  { 
256-         self . file_loader = file_loader; 
257-         self 
258-     } 
259- 
260-     /// Set the session-global flag that checks whether internal features have been used, 
261- /// suppressing the message about submitting an issue in ICEs when enabled. 
262- [ must_use] 
263-     pub  fn  set_using_internal_features( mut  self ,  using_internal_features:  Arc <AtomicBool >)  -> Self  { 
264-         self . using_internal_features = using_internal_features; 
265-         self 
266-     } 
267- 
268-     /// Parse args and run the compiler. 
269- pub  fn  run( self )  { 
270-         run_compiler( 
271-             self . at_args, 
272-             self . callbacks, 
273-             self . file_loader, 
274-             self . make_codegen_backend, 
275-             self . using_internal_features, 
276-         ) ; 
277-     } 
278- } 
279- 
280- fn  run_compiler( 
281-     at_args:  & [ String ] , 
282-     callbacks:  & mut  ( dyn Callbacks  + Send ) , 
283-     file_loader:  Option <Box <dyn FileLoader  + Send  + Sync >>, 
284-     make_codegen_backend:  Option <
285-         Box <dyn FnOnce ( & config:: Options )  -> Box <dyn CodegenBackend > + Send >, 
286-     >, 
287-     using_internal_features:  Arc <std:: sync:: atomic:: AtomicBool >, 
288- )  { 
210+ pub  fn  run_compiler( at_args:  & [ String ] ,  callbacks:  & mut  ( dyn Callbacks  + Send ) )  { 
289211    let  mut  default_early_dcx = EarlyDiagCtxt :: new( ErrorOutputType :: default ( ) ) ; 
290212
291213    // Throw away the first argument, the name of the binary. 
@@ -322,16 +244,16 @@ fn run_compiler(
322244        output_file:  ofile, 
323245        output_dir:  odir, 
324246        ice_file, 
325-         file_loader, 
247+         file_loader:   None , 
326248        locale_resources:  DEFAULT_LOCALE_RESOURCES . to_vec( ) , 
327249        lint_caps:  Default :: default ( ) , 
328250        psess_created:  None , 
329251        hash_untracked_state:  None , 
330252        register_lints:  None , 
331253        override_queries:  None , 
332-         make_codegen_backend, 
254+         make_codegen_backend:   None , 
333255        registry:  diagnostics_registry( ) , 
334-         using_internal_features, 
256+         using_internal_features:   & USING_INTERNAL_FEATURES , 
335257        expanded_args:  args, 
336258    } ; 
337259
@@ -1350,6 +1272,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
13501272    } ) 
13511273} 
13521274
1275+ pub  static  USING_INTERNAL_FEATURES :  AtomicBool  = AtomicBool :: new( false ) ; 
1276+ 
13531277/// Installs a panic hook that will print the ICE message on unexpected panics. 
13541278/// 
13551279/// The hook is intended to be useable even by external tools. You can pass a custom 
@@ -1360,15 +1284,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
13601284/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to 
13611285/// extra_info. 
13621286/// 
1363- /// Returns a flag that can be set to disable the note for submitting a bug. This can be passed to 
1364- /// [`RunCompiler::set_using_internal_features`] to let macro expansion set it when encountering 
1365- /// internal features. 
1366- /// 
13671287/// A custom rustc driver can skip calling this to set up a custom ICE hook. 
1368- pub  fn  install_ice_hook( 
1369-     bug_report_url:  & ' static  str , 
1370-     extra_info:  fn ( & DiagCtxt ) , 
1371- )  -> Arc <AtomicBool > { 
1288+ pub  fn  install_ice_hook( bug_report_url:  & ' static  str ,  extra_info:  fn ( & DiagCtxt ) )  { 
13721289    // If the user has not explicitly overridden "RUST_BACKTRACE", then produce 
13731290    // full backtraces. When a compiler ICE happens, we want to gather 
13741291    // as much information as possible to present in the issue opened 
@@ -1385,8 +1302,6 @@ pub fn install_ice_hook(
13851302        } 
13861303    } 
13871304
1388-     let  using_internal_features = Arc :: new( std:: sync:: atomic:: AtomicBool :: default ( ) ) ; 
1389-     let  using_internal_features_hook = Arc :: clone( & using_internal_features) ; 
13901305    panic:: update_hook( Box :: new( 
13911306        move |default_hook:  & ( dyn Fn ( & PanicHookInfo <' _>)  + Send  + Sync  + ' static ) , 
13921307              info:  & PanicHookInfo <' _>| { 
@@ -1438,11 +1353,9 @@ pub fn install_ice_hook(
14381353            } 
14391354
14401355            // Print the ICE message 
1441-             report_ice( info,  bug_report_url,  extra_info,  & using_internal_features_hook ) ; 
1356+             report_ice( info,  bug_report_url,  extra_info,  & USING_INTERNAL_FEATURES ) ; 
14421357        } , 
14431358    ) ) ; 
1444- 
1445-     using_internal_features
14461359} 
14471360
14481361/// Prints the ICE message, including query stack, but without backtrace. 
@@ -1583,13 +1496,11 @@ pub fn main() -> ! {
15831496    init_rustc_env_logger( & early_dcx) ; 
15841497    signal_handler:: install( ) ; 
15851498    let  mut  callbacks = TimePassesCallbacks :: default ( ) ; 
1586-     let  using_internal_features =  install_ice_hook( DEFAULT_BUG_REPORT_URL ,  |_| ( ) ) ; 
1499+     install_ice_hook( DEFAULT_BUG_REPORT_URL ,  |_| ( ) ) ; 
15871500    install_ctrlc_handler( ) ; 
15881501
15891502    let  exit_code = catch_with_exit_code( || { 
1590-         RunCompiler :: new( & args:: raw_args( & early_dcx) ?,  & mut  callbacks) 
1591-             . set_using_internal_features( using_internal_features) 
1592-             . run( ) ; 
1503+         run_compiler( & args:: raw_args( & early_dcx) ?,  & mut  callbacks) ; 
15931504        Ok ( ( ) ) 
15941505    } ) ; 
15951506
0 commit comments