@@ -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:: OffsetDateTime ;
66
66
@@ -223,11 +223,18 @@ pub struct RunCompiler<'a, 'b> {
223
223
file_loader: Option <Box <dyn FileLoader + Send + Sync >>,
224
224
make_codegen_backend:
225
225
Option <Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >>,
226
+ using_internal_features: Arc <std:: sync:: atomic:: AtomicBool >,
226
227
}
227
228
228
229
impl <' a, ' b> RunCompiler <' a, ' b> {
229
230
pub fn new( at_args: & ' a [ String ] , callbacks: & ' b mut ( dyn Callbacks + Send ) ) -> Self {
230
- Self { at_args, callbacks, file_loader: None , make_codegen_backend: None }
231
+ Self {
232
+ at_args,
233
+ callbacks,
234
+ file_loader: None ,
235
+ make_codegen_backend: None ,
236
+ using_internal_features: Arc :: default ( ) ,
237
+ }
231
238
}
232
239
233
240
/// Set a custom codegen backend.
@@ -259,9 +266,23 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
259
266
self
260
267
}
261
268
269
+ /// Set the session-global flag that checks whether internal features have been used,
270
+ /// suppressing the message about submitting an issue in ICEs when enabled.
271
+ #[ must_use]
272
+ pub fn set_using_internal_features( mut self , using_internal_features: Arc <AtomicBool >) -> Self {
273
+ self . using_internal_features = using_internal_features;
274
+ self
275
+ }
276
+
262
277
/// Parse args and run the compiler.
263
278
pub fn run( self ) -> interface:: Result <( ) > {
264
- run_compiler( self . at_args, self . callbacks, self . file_loader, self . make_codegen_backend)
279
+ run_compiler(
280
+ self . at_args,
281
+ self . callbacks,
282
+ self . file_loader,
283
+ self . make_codegen_backend,
284
+ self . using_internal_features,
285
+ )
265
286
}
266
287
}
267
288
@@ -272,6 +293,7 @@ fn run_compiler(
272
293
make_codegen_backend: Option <
273
294
Box <dyn FnOnce ( & config:: Options ) -> Box <dyn CodegenBackend > + Send >,
274
295
>,
296
+ using_internal_features: Arc <std:: sync:: atomic:: AtomicBool >,
275
297
) -> interface:: Result <( ) > {
276
298
let mut early_error_handler = EarlyErrorHandler :: new( ErrorOutputType :: default ( ) ) ;
277
299
@@ -316,6 +338,7 @@ fn run_compiler(
316
338
override_queries: None ,
317
339
make_codegen_backend,
318
340
registry: diagnostics_registry( ) ,
341
+ using_internal_features,
319
342
expanded_args: args,
320
343
} ;
321
344
@@ -1333,8 +1356,12 @@ fn ice_path() -> &'static Option<PathBuf> {
1333
1356
/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to
1334
1357
/// extra_info.
1335
1358
///
1359
+ /// Returns a flag that can be set to disable the note for submitting a bug. This can be passed to
1360
+ /// [`RunCompiler::set_using_internal_features`] to let macro expansion set it when encountering
1361
+ /// internal features.
1362
+ ///
1336
1363
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
1337
- pub fn install_ice_hook( bug_report_url: & ' static str , extra_info: fn ( & Handler ) ) {
1364
+ pub fn install_ice_hook( bug_report_url: & ' static str , extra_info: fn ( & Handler ) ) -> Arc < AtomicBool > {
1338
1365
// If the user has not explicitly overridden "RUST_BACKTRACE", then produce
1339
1366
// full backtraces. When a compiler ICE happens, we want to gather
1340
1367
// as much information as possible to present in the issue opened
@@ -1345,6 +1372,8 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
1345
1372
std:: env:: set_var( "RUST_BACKTRACE" , "full" ) ;
1346
1373
}
1347
1374
1375
+ let using_internal_features = Arc :: new( std:: sync:: atomic:: AtomicBool :: default ( ) ) ;
1376
+ let using_internal_features_hook = using_internal_features. clone( ) ;
1348
1377
panic:: update_hook( Box :: new(
1349
1378
move |default_hook: & ( dyn Fn ( & PanicInfo <' _>) + Send + Sync + ' static ) ,
1350
1379
info: & PanicInfo <' _>| {
@@ -1394,9 +1423,11 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
1394
1423
}
1395
1424
1396
1425
// Print the ICE message
1397
- report_ice( info, bug_report_url, extra_info) ;
1426
+ report_ice( info, bug_report_url, extra_info, & using_internal_features_hook ) ;
1398
1427
} ,
1399
1428
) ) ;
1429
+
1430
+ using_internal_features
1400
1431
}
1401
1432
1402
1433
/// Prints the ICE message, including query stack, but without backtrace.
@@ -1405,7 +1436,12 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
1405
1436
///
1406
1437
/// When `install_ice_hook` is called, this function will be called as the panic
1407
1438
/// hook.
1408
- fn report_ice( info: & panic:: PanicInfo <' _>, bug_report_url: & str , extra_info: fn ( & Handler ) ) {
1439
+ fn report_ice(
1440
+ info: & panic:: PanicInfo <' _>,
1441
+ bug_report_url: & str ,
1442
+ extra_info: fn ( & Handler ) ,
1443
+ using_internal_features: & AtomicBool ,
1444
+ ) {
1409
1445
let fallback_bundle =
1410
1446
rustc_errors:: fallback_fluent_bundle( crate :: DEFAULT_LOCALE_RESOURCES . to_vec( ) , false ) ;
1411
1447
let emitter = Box :: new( rustc_errors:: emitter:: EmitterWriter :: stderr(
@@ -1422,7 +1458,11 @@ fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info: fn(
1422
1458
handler. emit_err( session_diagnostics:: Ice ) ;
1423
1459
}
1424
1460
1425
- handler. emit_note( session_diagnostics:: IceBugReport { bug_report_url } ) ;
1461
+ if using_internal_features. load( std:: sync:: atomic:: Ordering :: Relaxed ) {
1462
+ handler. emit_note( session_diagnostics:: IceBugReportInternalFeature ) ;
1463
+ } else {
1464
+ handler. emit_note( session_diagnostics:: IceBugReport { bug_report_url } ) ;
1465
+ }
1426
1466
1427
1467
let version = util:: version_str!( ) . unwrap_or( "unknown_version" ) ;
1428
1468
let triple = config:: host_triple( ) ;
@@ -1506,7 +1546,7 @@ pub fn main() -> ! {
1506
1546
init_rustc_env_logger( & handler) ;
1507
1547
signal_handler:: install( ) ;
1508
1548
let mut callbacks = TimePassesCallbacks :: default ( ) ;
1509
- install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1549
+ let using_internal_features = install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1510
1550
let exit_code = catch_with_exit_code( || {
1511
1551
let args = env:: args_os( )
1512
1552
. enumerate( )
@@ -1516,7 +1556,9 @@ pub fn main() -> ! {
1516
1556
} )
1517
1557
} )
1518
1558
. collect:: <Vec <_>>( ) ;
1519
- RunCompiler :: new( & args, & mut callbacks) . run( )
1559
+ RunCompiler :: new( & args, & mut callbacks)
1560
+ . set_using_internal_features( using_internal_features)
1561
+ . run( )
1520
1562
} ) ;
1521
1563
1522
1564
if let Some ( format) = callbacks. time_passes {
0 commit comments