Skip to content

Rollup of 6 pull requests #113454

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

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
906d2b1
Structurally normalize again for byte string lit pat checking
compiler-errors Jul 6, 2023
04903b0
On nightly, dump ICE backtraces to disk
estebank Mar 3, 2023
ca8202d
Remove variances_of on RPITIT gats, remove its one use-case
compiler-errors Jul 7, 2023
e6504df
Use `PathBuf::from` instead of `try_from`
estebank Jul 7, 2023
c70c82d
Add run-make test for ICE dump
estebank Jul 7, 2023
6ea7d7d
test fixme for CI
estebank Jul 7, 2023
4c99872
Require TAITs to be mentioned in the signatures of functions that reg…
oli-obk Jun 15, 2023
907f97e
Remove normalization from `opaque_types_defined_by`
oli-obk Jun 26, 2023
2f89c96
We don't need to track binders if we aren't normalizing
oli-obk Jun 26, 2023
a3ca139
liar liar find_taits_declared_in_body on fire
oli-obk Jun 29, 2023
af9dcf7
Remove one layer of nested matching on the same thing
oli-obk Jun 29, 2023
b07d27c
Move some logic into a method on `OpaqueTypeCollector`
oli-obk Jun 29, 2023
18f3d86
Collect nested items immediately instead of collecting them into an i…
oli-obk Jun 29, 2023
dcacfe7
Only match on the `DefKind` once.
oli-obk Jun 29, 2023
ef52dc7
Add regression test
oli-obk Jun 29, 2023
b549ba1
Fix one layer of closures not being able to constrain opaque types
oli-obk Jun 29, 2023
c3004a7
Treat closures as part of their parent
oli-obk Jun 29, 2023
7a83ef8
miri: check that assignments do not self-overlap
RalfJung Jul 7, 2023
d03b0f5
If re-export is private, get the next item until a public one is foun…
GuillaumeGomez Jul 5, 2023
e3b7035
Add regression test for #81141
GuillaumeGomez Jul 5, 2023
52a7615
Improve code readability
GuillaumeGomez Jul 7, 2023
f37a6b0
Extend issue-81141-private-reexport-in-public-api test to cover more …
GuillaumeGomez Jul 7, 2023
1d1951b
Rename `first_not_private` into `first_non_private`
GuillaumeGomez Jul 7, 2023
4a1e06b
Correctly handle `super` and `::`
GuillaumeGomez Jul 7, 2023
6ff62b2
Rollup merge of #108714 - estebank:ice_dump, r=oli-obk
GuillaumeGomez Jul 7, 2023
286268b
Rollup merge of #112652 - oli-obk:tait_only_in_sig, r=compiler-errors
GuillaumeGomez Jul 7, 2023
93bbb99
Rollup merge of #113374 - GuillaumeGomez:private-to-public-path, r=no…
GuillaumeGomez Jul 7, 2023
896958c
Rollup merge of #113399 - compiler-errors:next-solver-byte-pat-again,…
GuillaumeGomez Jul 7, 2023
ba711ba
Rollup merge of #113427 - compiler-errors:no-variances-of-rpitit-gat,…
GuillaumeGomez Jul 7, 2023
1553f4c
Rollup merge of #113441 - RalfJung:assign-no-overlap, r=oli-obk
GuillaumeGomez Jul 7, 2023
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
28 changes: 28 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3212,6 +3212,7 @@ dependencies = [
"rustc_trait_selection",
"rustc_ty_utils",
"serde_json",
"time",
"tracing",
"windows",
]
Expand Down Expand Up @@ -4815,6 +4816,33 @@ dependencies = [
name = "tier-check"
version = "0.1.0"

[[package]]
name = "time"
version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd"
dependencies = [
"itoa",
"serde",
"time-core",
"time-macros",
]

[[package]]
name = "time-core"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"

[[package]]
name = "time-macros"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b"
dependencies = [
"time-core",
]

[[package]]
name = "tinystr"
version = "0.7.1"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {

impl<B: WriteBackendMethods> CodegenContext<B> {
pub fn create_diag_handler(&self) -> Handler {
Handler::with_emitter(true, None, Box::new(self.diag_emitter.clone()))
Handler::with_emitter(true, None, Box::new(self.diag_emitter.clone()), None)
}

pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,13 @@ where
assert_eq!(src.layout.size, dest.layout.size);
}

// Setting `nonoverlapping` here only has an effect when we don't hit the fast-path above,
// but that should at least match what LLVM does where `memcpy` is also only used when the
// type does not have Scalar/ScalarPair layout.
// (Or as the `Assign` docs put it, assignments "not producing primitives" must be
// non-overlapping.)
self.mem_copy(
src.ptr, src.align, dest.ptr, dest.align, dest_size, /*nonoverlapping*/ false,
src.ptr, src.align, dest.ptr, dest.align, dest_size, /*nonoverlapping*/ true,
)
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[lib]

[dependencies]
time = { version = "0.3", default-features = false, features = ["formatting", ] }
tracing = { version = "0.1.35" }
serde_json = "1.0.59"
rustc_log = { path = "../rustc_log" }
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_driver_impl/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ driver_impl_ice_bug_report = 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}
driver_impl_ice_path = please attach the file at `{$path}` to your bug report
driver_impl_ice_path_error = the ICE couldn't be written to `{$path}`: {$error}
driver_impl_ice_path_error_env = the environment variable `RUSTC_ICE` is set to `{$env_var}`
driver_impl_ice_version = rustc {$version} running on {$triple}

driver_impl_rlink_empty_version_number = The input does not contain version number

driver_impl_rlink_encoding_version_mismatch = .rlink file was produced with encoding version `{$version_array}`, but the current version is `{$rlink_version}`
Expand Down
80 changes: 67 additions & 13 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(lazy_cell)]
#![feature(decl_macro)]
#![feature(ice_to_disk)]
#![feature(let_chains)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
Expand Down Expand Up @@ -57,8 +59,11 @@ use std::panic::{self, catch_unwind};
use std::path::PathBuf;
use std::process::{self, Command, Stdio};
use std::str;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
use std::time::Instant;
use std::time::{Instant, SystemTime};
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;

#[allow(unused_macros)]
macro do_not_use_print($($t:tt)*) {
Expand Down Expand Up @@ -297,6 +302,7 @@ fn run_compiler(
input: Input::File(PathBuf::new()),
output_file: ofile,
output_dir: odir,
ice_file: ice_path().clone(),
file_loader,
locale_resources: DEFAULT_LOCALE_RESOURCES,
lint_caps: Default::default(),
Expand Down Expand Up @@ -1295,9 +1301,29 @@ pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
}
}

/// Stores the default panic hook, from before [`install_ice_hook`] was called.
static DEFAULT_HOOK: OnceLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
OnceLock::new();
pub static ICE_PATH: OnceLock<Option<PathBuf>> = OnceLock::new();

pub fn ice_path() -> &'static Option<PathBuf> {
ICE_PATH.get_or_init(|| {
if !rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build() {
return None;
}
if let Ok("0") = std::env::var("RUST_BACKTRACE").as_deref() {
return None;
}
let mut path = match std::env::var("RUSTC_ICE").as_deref() {
// Explicitly opting out of writing ICEs to disk.
Ok("0") => return None,
Ok(s) => PathBuf::from(s),
Err(_) => std::env::current_dir().unwrap_or_default(),
};
let now: OffsetDateTime = SystemTime::now().into();
let file_now = now.format(&Rfc3339).unwrap_or(String::new());
let pid = std::process::id();
path.push(format!("rustc-ice-{file_now}-{pid}.txt"));
Some(path)
})
}

/// Installs a panic hook that will print the ICE message on unexpected panics.
///
Expand All @@ -1321,8 +1347,6 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
std::env::set_var("RUST_BACKTRACE", "full");
}

let default_hook = DEFAULT_HOOK.get_or_init(panic::take_hook);

panic::set_hook(Box::new(move |info| {
// If the error was caused by a broken pipe then this is not a bug.
// Write the error and return immediately. See #98700.
Expand All @@ -1339,7 +1363,7 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
// Don't do this for delayed bugs, which already emit their own more useful backtrace.
if !info.payload().is::<rustc_errors::DelayedBugPanic>() {
(*default_hook)(info);
std::panic_hook_with_disk_dump(info, ice_path().as_deref());

// Separate the output with an empty line
eprintln!();
Expand Down Expand Up @@ -1371,7 +1395,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info:
false,
TerminalUrl::No,
));
let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
let handler = rustc_errors::Handler::with_emitter(true, None, emitter, None);

// a .span_bug or .bug call has already printed what
// it wants to print.
Expand All @@ -1382,10 +1406,40 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info:
}

handler.emit_note(session_diagnostics::IceBugReport { bug_report_url });
handler.emit_note(session_diagnostics::IceVersion {
version: util::version_str!().unwrap_or("unknown_version"),
triple: config::host_triple(),
});

let version = util::version_str!().unwrap_or("unknown_version");
let triple = config::host_triple();

static FIRST_PANIC: AtomicBool = AtomicBool::new(true);

let file = if let Some(path) = ice_path().as_ref() {
// Create the ICE dump target file.
match crate::fs::File::options().create(true).append(true).open(&path) {
Ok(mut file) => {
handler
.emit_note(session_diagnostics::IcePath { path: path.display().to_string() });
if FIRST_PANIC.swap(false, Ordering::SeqCst) {
let _ = write!(file, "\n\nrustc version: {version}\nplatform: {triple}");
}
Some(file)
}
Err(err) => {
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
handler.emit_warning(session_diagnostics::IcePathError {
path: path.display().to_string(),
error: err.to_string(),
env_var: std::env::var("RUSTC_ICE")
.ok()
.map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }),
});
handler.emit_note(session_diagnostics::IceVersion { version, triple });
None
}
}
} else {
handler.emit_note(session_diagnostics::IceVersion { version, triple });
None
};

if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() {
handler.emit_note(session_diagnostics::IceFlags { flags: flags.join(" ") });
Expand All @@ -1399,7 +1453,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, extra_info:

let num_frames = if backtrace { None } else { Some(2) };

interface::try_print_query_stack(&handler, num_frames);
interface::try_print_query_stack(&handler, num_frames, file);

// We don't trust this callback not to panic itself, so run it at the end after we're sure we've
// printed all the relevant info.
Expand Down
23 changes: 22 additions & 1 deletion compiler/rustc_driver_impl/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_macros::Diagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};

#[derive(Diagnostic)]
#[diag(driver_impl_rlink_unable_to_read)]
Expand Down Expand Up @@ -56,6 +56,27 @@ pub(crate) struct IceVersion<'a> {
pub triple: &'a str,
}

#[derive(Diagnostic)]
#[diag(driver_impl_ice_path)]
pub(crate) struct IcePath {
pub path: String,
}

#[derive(Diagnostic)]
#[diag(driver_impl_ice_path_error)]
pub(crate) struct IcePathError {
pub path: String,
pub error: String,
#[subdiagnostic]
pub env_var: Option<IcePathErrorEnv>,
}

#[derive(Subdiagnostic)]
#[note(driver_impl_ice_path_error_env)]
pub(crate) struct IcePathErrorEnv {
pub env_var: String,
}

#[derive(Diagnostic)]
#[diag(driver_impl_ice_flags)]
pub(crate) struct IceFlags {
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn register_functions(bundle: &mut FluentBundle) {
pub type LazyFallbackBundle = Lrc<Lazy<FluentBundle, impl FnOnce() -> FluentBundle>>;

/// Return the default `FluentBundle` with standard "en-US" diagnostic messages.
#[instrument(level = "trace")]
#[instrument(level = "trace", skip(resources))]
pub fn fallback_fluent_bundle(
resources: Vec<&'static str>,
with_directionality_markers: bool,
Expand All @@ -242,7 +242,6 @@ pub fn fallback_fluent_bundle(
for resource in resources {
let resource = FluentResource::try_new(resource.to_string())
.expect("failed to parse fallback fluent resource");
trace!(?resource);
fallback_bundle.add_resource_overriding(resource);
}

Expand Down Expand Up @@ -355,6 +354,13 @@ impl DiagnosticMessage {
}
}
}

pub fn as_str(&self) -> Option<&str> {
match self {
DiagnosticMessage::Eager(s) | DiagnosticMessage::Str(s) => Some(s),
DiagnosticMessage::FluentIdentifier(_, _) => None,
}
}
}

impl From<String> for DiagnosticMessage {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
);

let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
let handler = Handler::with_emitter(true, None, Box::new(je));
let handler = Handler::with_emitter(true, None, Box::new(je), None);
handler.span_err(span, "foo");

let bytes = output.lock().unwrap();
Expand Down
Loading