@@ -60,7 +60,7 @@ use std::path::PathBuf;
60
60
use std:: process:: { self , Command , Stdio } ;
61
61
use std:: str;
62
62
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
63
- use std:: sync:: OnceLock ;
63
+ use std:: sync:: { Arc , OnceLock } ;
64
64
use std:: time:: { Instant , SystemTime } ;
65
65
use time:: format_description:: well_known:: Rfc3339 ;
66
66
use time:: OffsetDateTime ;
@@ -224,11 +224,18 @@ pub struct RunCompiler<'a, 'b> {
224
224
file_loader: Option <Box <dyn FileLoader + Send + Sync >>,
225
225
make_codegen_backend:
226
226
Option <Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >>,
227
+ using_internal_features: Option <Arc <std:: sync:: atomic:: AtomicBool >>,
227
228
}
228
229
229
230
impl <' a, ' b> RunCompiler <' a, ' b> {
230
231
pub fn new( at_args: & ' a [ String ] , callbacks: & ' b mut ( dyn Callbacks + Send ) ) -> Self {
231
- Self { at_args, callbacks, file_loader: None , make_codegen_backend: None }
232
+ Self {
233
+ at_args,
234
+ callbacks,
235
+ file_loader: None ,
236
+ make_codegen_backend: None ,
237
+ using_internal_features: None ,
238
+ }
232
239
}
233
240
234
241
/// Set a custom codegen backend.
@@ -260,9 +267,25 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
260
267
self
261
268
}
262
269
270
+ /// Set the session-global flag that checks whether internal features have been used,
271
+ /// suppressing the message about submitting an issue in ICEs when enabled.
272
+ pub fn set_using_internal_features(
273
+ & mut self ,
274
+ using_internal_features: Option <Arc <AtomicBool >>,
275
+ ) -> & mut Self {
276
+ self . using_internal_features = using_internal_features;
277
+ self
278
+ }
279
+
263
280
/// Parse args and run the compiler.
264
281
pub fn run( self ) -> interface:: Result <( ) > {
265
- run_compiler( self . at_args, self . callbacks, self . file_loader, self . make_codegen_backend)
282
+ run_compiler(
283
+ self . at_args,
284
+ self . callbacks,
285
+ self . file_loader,
286
+ self . make_codegen_backend,
287
+ self . using_internal_features,
288
+ )
266
289
}
267
290
}
268
291
@@ -273,6 +296,7 @@ fn run_compiler(
273
296
make_codegen_backend: Option <
274
297
Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >,
275
298
>,
299
+ using_internal_features: Option <Arc <std:: sync:: atomic:: AtomicBool >>,
276
300
) -> interface:: Result <( ) > {
277
301
let mut early_error_handler = EarlyErrorHandler :: new( ErrorOutputType :: default ( ) ) ;
278
302
@@ -316,6 +340,7 @@ fn run_compiler(
316
340
override_queries: None ,
317
341
make_codegen_backend,
318
342
registry: diagnostics_registry( ) ,
343
+ using_internal_features,
319
344
expanded_args: args,
320
345
} ;
321
346
@@ -1323,8 +1348,16 @@ fn ice_path() -> &'static Option<PathBuf> {
1323
1348
/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to
1324
1349
/// extra_info.
1325
1350
///
1351
+ /// If emitting the "please submit a bug" message is fine when internal features are enabled, `None`
1352
+ /// can be passed as the `using_internal_features`. To hide the note, pass in a bool that is also passed
1353
+ /// to [`RunCompiler::set_using_internal_features`].
1354
+ ///
1326
1355
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
1327
- pub fn install_ice_hook( bug_report_url: & ' static str , extra_info: fn ( & Handler ) ) {
1356
+ pub fn install_ice_hook(
1357
+ bug_report_url: & ' static str ,
1358
+ extra_info: fn ( & Handler ) ,
1359
+ using_internal_features: Option <Arc <AtomicBool >>,
1360
+ ) {
1328
1361
// If the user has not explicitly overridden "RUST_BACKTRACE", then produce
1329
1362
// full backtraces. When a compiler ICE happens, we want to gather
1330
1363
// as much information as possible to present in the issue opened
@@ -1384,7 +1417,7 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
1384
1417
}
1385
1418
1386
1419
// Print the ICE message
1387
- report_ice( info, bug_report_url, extra_info) ;
1420
+ report_ice( info, bug_report_url, extra_info, using_internal_features . clone ( ) ) ;
1388
1421
} ,
1389
1422
) ) ;
1390
1423
}
@@ -1395,7 +1428,12 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
1395
1428
///
1396
1429
/// When `install_ice_hook` is called, this function will be called as the panic
1397
1430
/// hook.
1398
- fn report_ice( info: & panic:: PanicInfo <' _>, bug_report_url: & str , extra_info: fn ( & Handler ) ) {
1431
+ fn report_ice(
1432
+ info: & panic:: PanicInfo <' _>,
1433
+ bug_report_url: & str ,
1434
+ extra_info: fn ( & Handler ) ,
1435
+ using_internal_features: Option <Arc <AtomicBool >>,
1436
+ ) {
1399
1437
let fallback_bundle =
1400
1438
rustc_errors:: fallback_fluent_bundle( crate :: DEFAULT_LOCALE_RESOURCES . to_vec( ) , false ) ;
1401
1439
let emitter = Box :: new( rustc_errors:: emitter:: EmitterWriter :: stderr(
@@ -1412,7 +1450,13 @@ fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info: fn(
1412
1450
handler. emit_err( session_diagnostics:: Ice ) ;
1413
1451
}
1414
1452
1415
- handler. emit_note( session_diagnostics:: IceBugReport { bug_report_url } ) ;
1453
+ if using_internal_features
1454
+ . map_or( false , |internal| internal. load( std:: sync:: atomic:: Ordering :: Relaxed ) )
1455
+ {
1456
+ handler. emit_note( session_diagnostics:: IceBugReportInternalFeature ) ;
1457
+ } else {
1458
+ handler. emit_note( session_diagnostics:: IceBugReport { bug_report_url } ) ;
1459
+ }
1416
1460
1417
1461
let version = util:: version_str!( ) . unwrap_or( "unknown_version" ) ;
1418
1462
let triple = config:: host_triple( ) ;
@@ -1493,10 +1537,12 @@ pub fn main() -> ! {
1493
1537
1494
1538
let handler = EarlyErrorHandler :: new( ErrorOutputType :: default ( ) ) ;
1495
1539
1540
+ let using_internal_features = Some ( Arc :: default ( ) ) ;
1541
+
1496
1542
init_rustc_env_logger( & handler) ;
1497
1543
signal_handler:: install( ) ;
1498
1544
let mut callbacks = TimePassesCallbacks :: default ( ) ;
1499
- install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1545
+ install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) , using_internal_features . clone ( ) ) ;
1500
1546
let exit_code = catch_with_exit_code( || {
1501
1547
let args = env:: args_os( )
1502
1548
. enumerate( )
@@ -1506,7 +1552,9 @@ pub fn main() -> ! {
1506
1552
} )
1507
1553
} )
1508
1554
. collect:: <Vec <_>>( ) ;
1509
- RunCompiler :: new( & args, & mut callbacks) . run( )
1555
+ let mut run = RunCompiler :: new( & args, & mut callbacks) ;
1556
+ run. set_using_internal_features( using_internal_features) ;
1557
+ run. run( )
1510
1558
} ) ;
1511
1559
1512
1560
if let Some ( format) = callbacks. time_passes {
0 commit comments