Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #122041

Merged
merged 20 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a5245ef
Hint user to update nightly on ICEs produced from outdated nightly
jieyouxu Feb 27, 2024
a0ca9b1
Don't suggest update nightly if using internal features
jieyouxu Feb 27, 2024
9c963fc
Adjust wording
jieyouxu Feb 27, 2024
89954e5
only compare ambiguity item that have hard error
bvanjoi Mar 1, 2024
6e9f59f
add test for #78894
surechen Mar 4, 2024
4e03c51
hir_analysis: enums return `None` in `find_field`
davidtwco Mar 4, 2024
640e99c
Fix duplicated path in the "not found dylib" error
GuillaumeGomez Mar 4, 2024
5e6e140
Add regression ui test for duplicated path in dylib error
GuillaumeGomez Mar 4, 2024
523ab25
add test for #71450
surechen Mar 4, 2024
9d9b26b
Limit the number of names and values in check-cfg diagnostics
Urgau Feb 16, 2024
2ee0409
errors: share `SilentEmitter` between rustc and rustfmt
davidtwco Feb 19, 2024
da35734
Merge `impl_trait_in_assoc_types_defined_by` query back into `opaque_…
oli-obk Mar 4, 2024
640648b
Rollup merge of #121202 - Urgau:check-cfg-limit-diagnostics, r=pnkfelix
matthiaskrgr Mar 5, 2024
9153451
Rollup merge of #121301 - davidtwco:rustfmt-silent-emitter, r=pnkfelix
matthiaskrgr Mar 5, 2024
1b30268
Rollup merge of #121658 - jieyouxu:ice-outdated-nightly, r=oli-obk
matthiaskrgr Mar 5, 2024
152b690
Rollup merge of #121846 - bvanjoi:fix-121760, r=petrochenkov
matthiaskrgr Mar 5, 2024
5cdf870
Rollup merge of #121961 - surechen:add_test_20240304, r=petrochenkov
matthiaskrgr Mar 5, 2024
f560806
Rollup merge of #121975 - davidtwco:issue-121757, r=petrochenkov
matthiaskrgr Mar 5, 2024
f5ff6d5
Rollup merge of #121978 - GuillaumeGomez:dylib-duplicated-path, r=bjorn3
matthiaskrgr Mar 5, 2024
3d6b3d0
Rollup merge of #121991 - oli-obk:merge_opaque_types_defined_by_queri…
matthiaskrgr Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Hint user to update nightly on ICEs produced from outdated nightly
  • Loading branch information
jieyouxu committed Feb 27, 2024
commit a5245ef284f70e048e9a4f6bbe1678067d0a3bb6
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
serde_json = "1.0.59"
shlex = "1.0"
time = { version = "0.3", default-features = false, features = ["alloc", "formatting"] }
time = { version = "0.3", default-features = false, features = ["alloc", "formatting", "parsing", "macros"] }
tracing = { version = "0.1.35" }
# tidy-alphabetical-end

Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_driver_impl/messages.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
driver_impl_ice = the compiler unexpectedly panicked. this is a bug.
driver_impl_ice_bug_report = we would appreciate a bug report: {$bug_report_url}
driver_impl_ice_bug_report_internal_feature = using internal features is not supported and expected to cause internal compiler errors when used incorrectly
driver_impl_ice_bug_report_internal_feature_outdated =
using internal features is not supported and expected to cause internal compiler errors when used incorrectly
.outdated = it seems this '{$version}' is outdated, a newer nightly should have been released in the mean time
.update = please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
driver_impl_ice_bug_report_outdated =
it seems this '{$version}' is outdated, a newer nightly should have been released in the mean time
.update = please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
.url = we would appreciate a bug report: {$bug_report_url}
driver_impl_ice_exclude_cargo_defaults = some of the compiler flags provided by cargo are hidden

driver_impl_ice_flags = compiler flags: {$flags}
Expand Down
42 changes: 38 additions & 4 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use std::str;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, OnceLock};
use std::time::{Instant, SystemTime};
use time::OffsetDateTime;
use time::{Date, OffsetDateTime, Time};

#[allow(unused_macros)]
macro do_not_use_print($($t:tt)*) {
Expand Down Expand Up @@ -1370,6 +1370,9 @@ pub fn install_ice_hook(
using_internal_features
}

const DATE_FORMAT: &[time::format_description::FormatItem<'static>] =
&time::macros::format_description!("[year]-[month]-[day]");

/// Prints the ICE message, including query stack, but without backtrace.
///
/// The message will point the user at `bug_report_url` to report the ICE.
Expand Down Expand Up @@ -1398,10 +1401,41 @@ fn report_ice(
dcx.emit_err(session_diagnostics::Ice);
}

if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
use time::ext::NumericalDuration;

// Try to hint user to update nightly if applicable when reporting an ICE.
// Attempt to calculate when current version was released, and add 12 hours
// as buffer. If the current version's release timestamp is older than
// the system's current time + 24 hours + 12 hours buffer if we're on
// nightly.
if let Some("nightly") = option_env!("CFG_RELEASE_CHANNEL")
&& let Some(version) = option_env!("CFG_VERSION")
&& let Some(ver_date_str) = option_env!("CFG_VER_DATE")
&& let Ok(ver_date) = Date::parse(&ver_date_str, DATE_FORMAT)
&& let ver_datetime = OffsetDateTime::new_utc(ver_date, Time::MIDNIGHT)
&& let system_datetime = OffsetDateTime::from(SystemTime::now())
&& system_datetime.checked_sub(36.hours()).is_some_and(|d| d > ver_datetime)
{
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
dcx.emit_note(session_diagnostics::IceBugReportInternalFeatureOutdated {
version,
note_update: (),
note_outdated: (),
});
} else {
dcx.emit_note(session_diagnostics::IceBugReportOutdated {
version,
bug_report_url,
note_update: (),
note_url: (),
});
}
} else {
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
} else {
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
}
}

let version = util::version_str!().unwrap_or("unknown_version");
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_driver_impl/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ pub(crate) struct IceBugReport<'a> {
#[diag(driver_impl_ice_bug_report_internal_feature)]
pub(crate) struct IceBugReportInternalFeature;

#[derive(Diagnostic)]
#[diag(driver_impl_ice_bug_report_outdated)]
pub(crate) struct IceBugReportOutdated<'a> {
pub version: &'a str,
pub bug_report_url: &'a str,
#[note(driver_impl_update)]
pub note_update: (),
#[note(driver_impl_url)]
pub note_url: (),
}

#[derive(Diagnostic)]
#[diag(driver_impl_ice_bug_report_internal_feature_outdated)]
pub(crate) struct IceBugReportInternalFeatureOutdated<'a> {
pub version: &'a str,
#[note(driver_impl_outdated)]
pub note_outdated: (),
#[note(driver_impl_update)]
pub note_update: (),
}

#[derive(Diagnostic)]
#[diag(driver_impl_ice_version)]
pub(crate) struct IceVersion<'a> {
Expand Down
Loading