Skip to content

Commit c7e77be

Browse files
committed
driver: unconditionally show update nightly hint
1 parent 2805aed commit c7e77be

File tree

3 files changed

+13
-45
lines changed

3 files changed

+13
-45
lines changed

Diff for: 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 = 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}

Diff for: compiler/rustc_driver_impl/src/lib.rs

+8-30
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,33 +1413,14 @@ 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 });
1419+
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1420+
1421+
// Only emit update nightly hint for users on nightly builds.
1422+
if rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build() {
1423+
dcx.emit_note(session_diagnostics::UpdateNightlyNote);
14461424
}
14471425
}
14481426

Diff for: 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)]

0 commit comments

Comments
 (0)