@@ -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
@@ -214,18 +214,11 @@ pub struct RunCompiler<'a> {
214214 file_loader: Option <Box <dyn FileLoader + Send + Sync >>,
215215 make_codegen_backend:
216216 Option <Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >>,
217- using_internal_features: Arc <std:: sync:: atomic:: AtomicBool >,
218217}
219218
220219impl <' a> RunCompiler <' a> {
221220 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- }
221+ Self { at_args, callbacks, file_loader: None , make_codegen_backend: None }
229222 }
230223
231224 /// Set a custom codegen backend.
@@ -257,23 +250,9 @@ impl<'a> RunCompiler<'a> {
257250 self
258251 }
259252
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-
268253 /// Parse args and run the compiler.
269254 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- ) ;
255+ run_compiler( self . at_args, self . callbacks, self . file_loader, self . make_codegen_backend) ;
277256 }
278257}
279258
@@ -284,7 +263,6 @@ fn run_compiler(
284263 make_codegen_backend: Option <
285264 Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >,
286265 >,
287- using_internal_features: Arc <std:: sync:: atomic:: AtomicBool >,
288266) {
289267 let mut default_early_dcx = EarlyDiagCtxt :: new( ErrorOutputType :: default ( ) ) ;
290268
@@ -331,7 +309,7 @@ fn run_compiler(
331309 override_queries: None ,
332310 make_codegen_backend,
333311 registry: diagnostics_registry( ) ,
334- using_internal_features,
312+ using_internal_features: & USING_INTERNAL_FEATURES ,
335313 expanded_args: args,
336314 } ;
337315
@@ -1350,6 +1328,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
13501328 } )
13511329}
13521330
1331+ pub static USING_INTERNAL_FEATURES : AtomicBool = AtomicBool :: new( false ) ;
1332+
13531333/// Installs a panic hook that will print the ICE message on unexpected panics.
13541334///
13551335/// The hook is intended to be useable even by external tools. You can pass a custom
@@ -1360,15 +1340,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
13601340/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to
13611341/// extra_info.
13621342///
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- ///
13671343/// 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 > {
1344+ pub fn install_ice_hook( bug_report_url: & ' static str , extra_info: fn ( & DiagCtxt ) ) {
13721345 // If the user has not explicitly overridden "RUST_BACKTRACE", then produce
13731346 // full backtraces. When a compiler ICE happens, we want to gather
13741347 // as much information as possible to present in the issue opened
@@ -1385,8 +1358,6 @@ pub fn install_ice_hook(
13851358 }
13861359 }
13871360
1388- let using_internal_features = Arc :: new( std:: sync:: atomic:: AtomicBool :: default ( ) ) ;
1389- let using_internal_features_hook = Arc :: clone( & using_internal_features) ;
13901361 panic:: update_hook( Box :: new(
13911362 move |default_hook: & ( dyn Fn ( & PanicHookInfo <' _>) + Send + Sync + ' static ) ,
13921363 info: & PanicHookInfo <' _>| {
@@ -1438,11 +1409,9 @@ pub fn install_ice_hook(
14381409 }
14391410
14401411 // Print the ICE message
1441- report_ice( info, bug_report_url, extra_info, & using_internal_features_hook ) ;
1412+ report_ice( info, bug_report_url, extra_info, & USING_INTERNAL_FEATURES ) ;
14421413 } ,
14431414 ) ) ;
1444-
1445- using_internal_features
14461415}
14471416
14481417/// Prints the ICE message, including query stack, but without backtrace.
@@ -1583,13 +1552,11 @@ pub fn main() -> ! {
15831552 init_rustc_env_logger( & early_dcx) ;
15841553 signal_handler:: install( ) ;
15851554 let mut callbacks = TimePassesCallbacks :: default ( ) ;
1586- let using_internal_features = install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1555+ install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
15871556 install_ctrlc_handler( ) ;
15881557
15891558 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( ) ;
1559+ RunCompiler :: new( & args:: raw_args( & early_dcx) ?, & mut callbacks) . run( ) ;
15931560 Ok ( ( ) )
15941561 } ) ;
15951562
0 commit comments