Skip to content

Commit a1cb4c2

Browse files
committed
Unconditionally show update nightly hint on ICE
1 parent 1b2c53a commit a1cb4c2

File tree

8 files changed

+20
-46
lines changed

8 files changed

+20
-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 mean time
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
@@ -59,7 +59,7 @@ use std::str;
5959
use std::sync::atomic::{AtomicBool, Ordering};
6060
use std::sync::{Arc, OnceLock};
6161
use std::time::{Instant, SystemTime};
62-
use time::{Date, OffsetDateTime, Time};
62+
use time::OffsetDateTime;
6363

6464
#[allow(unused_macros)]
6565
macro do_not_use_print($($t:tt)*) {
@@ -1370,9 +1370,6 @@ pub fn install_ice_hook(
13701370
using_internal_features
13711371
}
13721372

1373-
const DATE_FORMAT: &[time::format_description::FormatItem<'static>] =
1374-
&time::macros::format_description!("[year]-[month]-[day]");
1375-
13761373
/// Prints the ICE message, including query stack, but without backtrace.
13771374
///
13781375
/// The message will point the user at `bug_report_url` to report the ICE.
@@ -1401,34 +1398,11 @@ fn report_ice(
14011398
dcx.emit_err(session_diagnostics::Ice);
14021399
}
14031400

1404-
use time::ext::NumericalDuration;
1405-
1406-
// Try to hint user to update nightly if applicable when reporting an ICE.
1407-
// Attempt to calculate when current version was released, and add 12 hours
1408-
// as buffer. If the current version's release timestamp is older than
1409-
// the system's current time + 24 hours + 12 hours buffer if we're on
1410-
// nightly.
1411-
if let Some("nightly") = option_env!("CFG_RELEASE_CHANNEL")
1412-
&& let Some(version) = option_env!("CFG_VERSION")
1413-
&& let Some(ver_date_str) = option_env!("CFG_VER_DATE")
1414-
&& let Ok(ver_date) = Date::parse(&ver_date_str, DATE_FORMAT)
1415-
&& let ver_datetime = OffsetDateTime::new_utc(ver_date, Time::MIDNIGHT)
1416-
&& let system_datetime = OffsetDateTime::from(SystemTime::now())
1417-
&& system_datetime.checked_sub(36.hours()).is_some_and(|d| d > ver_datetime)
1418-
&& !using_internal_features.load(std::sync::atomic::Ordering::Relaxed)
1419-
{
1420-
dcx.emit_note(session_diagnostics::IceBugReportOutdated {
1421-
version,
1422-
bug_report_url,
1423-
note_update: (),
1424-
note_url: (),
1425-
});
1401+
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1402+
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
14261403
} else {
1427-
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1428-
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
1429-
} else {
1430-
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1431-
}
1404+
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1405+
dcx.emit_note(session_diagnostics::UpdateNightlyNote);
14321406
}
14331407

14341408
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/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)