Skip to content

Commit ec2a36b

Browse files
committed
Unconditionally show update nightly hint on ICE
1 parent ab3dba9 commit ec2a36b

File tree

9 files changed

+22
-46
lines changed

9 files changed

+22
-46
lines changed

compiler/rustc_driver_impl/messages.ftl

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
driver_impl_ice = the compiler unexpectedly panicked. this is a bug.
22
driver_impl_ice_bug_report = we would appreciate a bug report: {$bug_report_url}
33
driver_impl_ice_bug_report_internal_feature = using internal features is not supported and expected to cause internal compiler errors when used incorrectly
4-
driver_impl_ice_bug_report_outdated =
5-
it seems that this compiler `{$version}` is outdated, a newer nightly should have been released in the meantime
6-
.update = please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
7-
.url = if the problem still persists, we would appreciate a bug report: {$bug_report_url}
4+
driver_impl_ice_bug_report_update_note = if you are using a nightly compiler, please make sure that you have updated to the latest nightly
85
driver_impl_ice_exclude_cargo_defaults = some of the compiler flags provided by cargo are hidden
96
107
driver_impl_ice_flags = compiler flags: {$flags}

compiler/rustc_driver_impl/src/lib.rs

+5-31
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use std::str;
6161
use std::sync::atomic::{AtomicBool, Ordering};
6262
use std::sync::{Arc, OnceLock};
6363
use std::time::{Instant, SystemTime};
64-
use time::{Date, OffsetDateTime, Time};
64+
use time::OffsetDateTime;
6565

6666
#[allow(unused_macros)]
6767
macro do_not_use_print($($t:tt)*) {
@@ -1385,9 +1385,6 @@ pub fn install_ice_hook(
13851385
using_internal_features
13861386
}
13871387

1388-
const DATE_FORMAT: &[time::format_description::FormatItem<'static>] =
1389-
&time::macros::format_description!("[year]-[month]-[day]");
1390-
13911388
/// Prints the ICE message, including query stack, but without backtrace.
13921389
///
13931390
/// The message will point the user at `bug_report_url` to report the ICE.
@@ -1416,34 +1413,11 @@ fn report_ice(
14161413
dcx.emit_err(session_diagnostics::Ice);
14171414
}
14181415

1419-
use time::ext::NumericalDuration;
1420-
1421-
// Try to hint user to update nightly if applicable when reporting an ICE.
1422-
// Attempt to calculate when current version was released, and add 12 hours
1423-
// as buffer. If the current version's release timestamp is older than
1424-
// the system's current time + 24 hours + 12 hours buffer if we're on
1425-
// nightly.
1426-
if let Some("nightly") = option_env!("CFG_RELEASE_CHANNEL")
1427-
&& let Some(version) = option_env!("CFG_VERSION")
1428-
&& let Some(ver_date_str) = option_env!("CFG_VER_DATE")
1429-
&& let Ok(ver_date) = Date::parse(&ver_date_str, DATE_FORMAT)
1430-
&& let ver_datetime = OffsetDateTime::new_utc(ver_date, Time::MIDNIGHT)
1431-
&& let system_datetime = OffsetDateTime::from(SystemTime::now())
1432-
&& system_datetime.checked_sub(36.hours()).is_some_and(|d| d > ver_datetime)
1433-
&& !using_internal_features.load(std::sync::atomic::Ordering::Relaxed)
1434-
{
1435-
dcx.emit_note(session_diagnostics::IceBugReportOutdated {
1436-
version,
1437-
bug_report_url,
1438-
note_update: (),
1439-
note_url: (),
1440-
});
1416+
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1417+
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
14411418
} else {
1442-
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1443-
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
1444-
} else {
1445-
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1446-
}
1419+
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1420+
dcx.emit_note(session_diagnostics::UpdateNightlyNote);
14471421
}
14481422

14491423
let version = util::version_str!().unwrap_or("unknown_version");

compiler/rustc_driver_impl/src/session_diagnostics.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,12 @@ pub(crate) struct IceBugReport<'a> {
4343
}
4444

4545
#[derive(Diagnostic)]
46-
#[diag(driver_impl_ice_bug_report_internal_feature)]
47-
pub(crate) struct IceBugReportInternalFeature;
46+
#[diag(driver_impl_ice_bug_report_update_note)]
47+
pub(crate) struct UpdateNightlyNote;
4848

4949
#[derive(Diagnostic)]
50-
#[diag(driver_impl_ice_bug_report_outdated)]
51-
pub(crate) struct IceBugReportOutdated<'a> {
52-
pub version: &'a str,
53-
pub bug_report_url: &'a str,
54-
#[note(driver_impl_update)]
55-
pub note_update: (),
56-
#[note(driver_impl_url)]
57-
pub note_url: (),
58-
}
50+
#[diag(driver_impl_ice_bug_report_internal_feature)]
51+
pub(crate) struct IceBugReportInternalFeature;
5952

6053
#[derive(Diagnostic)]
6154
#[diag(driver_impl_ice_version)]

tests/rustdoc-ui/ice-bug-report-url.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ error: the compiler unexpectedly panicked. this is a bug.
1212

1313
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md
1414

15+
note: if you are using a nightly compiler, please make sure that you have updated to the latest nightly
16+
1517
note: rustc {version} running on {platform}
1618

1719
query stack during panic:

tests/ui/consts/const-eval/const-eval-query-stack.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ error: internal compiler error[E0080]: evaluation of constant value failed
44
LL | const X: i32 = 1 / 0;
55
| ^^^^^ attempt to divide `1_i32` by zero
66

7+
note: if you are using a nightly compiler, please make sure that you have updated to the latest nightly
8+
79
query stack during panic:
810
#0 [eval_to_allocation_raw] const-evaluating + checking `X`
911
#1 [eval_to_const_value_raw] simplifying constant for the type system `X`

tests/ui/impl-trait/equality-in-canonical-query.clone.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ LL | same_output(foo, rpit);
1919
LL | same_output(foo, rpit);
2020
| ^^^^^^^^^^^^^^^^^^^^^^
2121

22+
note: if you are using a nightly compiler, please make sure that you have updated to the latest nightly
23+
2224
query stack during panic:
2325
end of query stack

tests/ui/panics/default-backtrace-ice.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ error: the compiler unexpectedly panicked. this is a bug.
2020

2121

2222

23+
24+
2325
query stack during panic:
2426
#0 [resolver_for_lowering_raw] getting the resolver for lowering
2527
end of query stack

tests/ui/track-diagnostics/track.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3030

3131
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
3232

33+
note: if you are using a nightly compiler, please make sure that you have updated to the latest nightly
34+
3335
note: rustc $VERSION running on $TARGET
3436

3537
note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics

tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ LL | query(get_rpit);
1919
LL | query(get_rpit);
2020
| ^^^^^^^^^^^^^^^
2121

22+
note: if you are using a nightly compiler, please make sure that you have updated to the latest nightly
23+
2224
query stack during panic:
2325
end of query stack

0 commit comments

Comments
 (0)