From abf401df1c6326a5c701061aa49b9b64554d38c2 Mon Sep 17 00:00:00 2001 From: Kent Ross Date: Wed, 16 Apr 2025 18:53:40 -0700 Subject: [PATCH 01/10] fix missing word in comment --- library/core/src/any.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 10f2a11d558be..7aa3f3c6d7434 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -772,8 +772,8 @@ impl hash::Hash for TypeId { // (especially given the previous point about the lower 64 bits being // high quality on their own). // - It is correct to do so -- only hashing a subset of `self` is still - // with an `Eq` implementation that considers the entire value, as - // ours does. + // compatible with an `Eq` implementation that considers the entire + // value, as ours does. self.t.1.hash(state); } } From 88bd1913f2804c9204b72f60b61aad4449d832c3 Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 17 Apr 2025 11:37:54 -0500 Subject: [PATCH 02/10] Point UNIX_EPOCH to associated constant in SystemTime docs --- library/std/src/time.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 5ab71413586dc..6e28596e79b17 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -245,6 +245,7 @@ pub struct Instant(time::Instant); /// > structure cannot represent the new point in time. /// /// [`add`]: SystemTime::add +/// [`UNIX_EPOCH`]: SystemTime::UNIX_EPOCH #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "time2", since = "1.8.0")] pub struct SystemTime(time::SystemTime); From 34573d683f604ce4d1ab9a845c5a8be4a587a91d Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 17 Apr 2025 11:42:53 -0500 Subject: [PATCH 03/10] Be more specific about the error in the SystemTime example --- library/std/src/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 6e28596e79b17..03af35e809c91 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -205,8 +205,8 @@ pub struct Instant(time::Instant); /// println!("{}", elapsed.as_secs()); /// } /// Err(e) => { -/// // an error occurred! -/// println!("Error: {e:?}"); +/// // the system clock went backwards! +/// println!("Great Scott! {e:?}"); /// } /// } /// } From 0d56e3eed1c5f3edea5cae6171e7a706ad792463 Mon Sep 17 00:00:00 2001 From: Lieselotte <52315535+she3py@users.noreply.github.com> Date: Fri, 18 Apr 2025 12:29:51 +0200 Subject: [PATCH 04/10] LocalKey: document that the dtor should not panic --- library/std/src/thread/local.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index d5a5d10205dd8..7cd448733130d 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -22,12 +22,16 @@ use crate::fmt; /// /// Initialization is dynamically performed on the first call to a setter (e.g. /// [`with`]) within a thread, and values that implement [`Drop`] get -/// destructed when a thread exits. Some caveats apply, which are explained below. +/// destructed when a thread exits. Some platform-specific caveats apply, which +/// are explained below. +/// Note that, should the destructor panics, the whole process will be [aborted]. /// /// A `LocalKey`'s initializer cannot recursively depend on itself. Using a /// `LocalKey` in this way may cause panics, aborts or infinite recursion on /// the first call to `with`. /// +/// [aborted]: crate::process::abort +/// /// # Single-thread Synchronization /// /// Though there is no potential race with other threads, it is still possible to From 17b7d63fd787699dac3fffbf9930dc799291a5f2 Mon Sep 17 00:00:00 2001 From: Lieselotte <52315535+she3py@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:02:22 +0200 Subject: [PATCH 05/10] rtprintpanic: clarify that the error is aborting the process --- library/std/src/rt.rs | 2 +- .../miri/tests/fail/panic/tls_macro_const_drop_panic.stderr | 2 +- src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr | 2 +- tests/ui/runtime/rt-explody-panic-payloads.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs index 3a22a16cb165e..9737b2f5bfe60 100644 --- a/library/std/src/rt.rs +++ b/library/std/src/rt.rs @@ -46,7 +46,7 @@ macro_rules! rtprintpanic { macro_rules! rtabort { ($($t:tt)*) => { { - rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*)); + rtprintpanic!("fatal runtime error: {}, aborting\n", format_args!($($t)*)); crate::sys::abort_internal(); } } diff --git a/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr b/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr index aadb9976609c3..1dcdb4a399680 100644 --- a/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr @@ -1,7 +1,7 @@ thread $NAME panicked at tests/fail/panic/tls_macro_const_drop_panic.rs:LL:CC: ow -fatal runtime error: thread local panicked on drop +fatal runtime error: thread local panicked on drop, aborting error: abnormal termination: the program aborted execution error: aborting due to 1 previous error diff --git a/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr b/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr index 546ee7e1ed214..7e4907abd9336 100644 --- a/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr @@ -1,7 +1,7 @@ thread $NAME panicked at tests/fail/panic/tls_macro_drop_panic.rs:LL:CC: ow -fatal runtime error: thread local panicked on drop +fatal runtime error: thread local panicked on drop, aborting error: abnormal termination: the program aborted execution error: aborting due to 1 previous error diff --git a/tests/ui/runtime/rt-explody-panic-payloads.rs b/tests/ui/runtime/rt-explody-panic-payloads.rs index c177fd260ed4f..d564a26ca7374 100644 --- a/tests/ui/runtime/rt-explody-panic-payloads.rs +++ b/tests/ui/runtime/rt-explody-panic-payloads.rs @@ -27,6 +27,6 @@ fn main() { // by QEMU in the stderr whenever a core dump happens. Remove it before the check. v.strip_suffix("qemu: uncaught target signal 6 (Aborted) - core dumped\n").unwrap_or(v) }) - .map(|v| { v.ends_with("fatal runtime error: drop of the panic payload panicked\n") }) + .map(|v| v.ends_with("fatal runtime error: drop of the panic payload panicked, aborting\n")) .unwrap_or(false)); } From b3739f3c0e86a217599f78d99920867f30afdd18 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 19 Apr 2025 03:36:02 -0400 Subject: [PATCH 06/10] Only consider MonoItem::Fn when preventing inlining for autodiff source functions --- compiler/rustc_monomorphize/src/partitioning.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index b1b6f10e0fe2c..d7690a96e10de 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -254,8 +254,9 @@ where always_export_generics, ); - // We can't differentiate something that got inlined. + // We can't differentiate a function that got inlined. let autodiff_active = cfg!(llvm_enzyme) + && matches!(mono_item, MonoItem::Fn(_)) && cx .tcx .codegen_fn_attrs(mono_item.def_id()) From 47911eb677a29006d243a0b6bf17f26486191ead Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 18 Apr 2025 23:36:17 +0000 Subject: [PATCH 07/10] Don't ICE on pending obligations from deep normalization in a loop --- .../src/traits/normalize.rs | 10 +- tests/crashes/133868.rs | 13 -- tests/ui/traits/deep-norm-pending.rs | 24 ++++ tests/ui/traits/deep-norm-pending.stderr | 130 ++++++++++++++++++ 4 files changed, 163 insertions(+), 14 deletions(-) delete mode 100644 tests/crashes/133868.rs create mode 100644 tests/ui/traits/deep-norm-pending.rs create mode 100644 tests/ui/traits/deep-norm-pending.stderr diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index 4ac45172a0e1c..7551ac5aa9735 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -77,7 +77,15 @@ impl<'tcx> At<'_, 'tcx> { .into_value_registering_obligations(self.infcx, &mut *fulfill_cx); let errors = fulfill_cx.select_all_or_error(self.infcx); let value = self.infcx.resolve_vars_if_possible(value); - if errors.is_empty() { Ok(value) } else { Err(errors) } + if errors.is_empty() { + Ok(value) + } else { + // Drop pending obligations, since deep normalization may happen + // in a loop and we don't want to trigger the assertion on the next + // iteration due to pending ambiguous obligations we've left over. + let _ = fulfill_cx.collect_remaining_errors(self.infcx); + Err(errors) + } } } } diff --git a/tests/crashes/133868.rs b/tests/crashes/133868.rs deleted file mode 100644 index dc25cb9df288e..0000000000000 --- a/tests/crashes/133868.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #133868 - -trait Foo { - type Assoc; -} - -trait Bar { - fn method() -> impl Sized; -} -impl Bar for T where ::Assoc: Sized -{ - fn method() {} -} diff --git a/tests/ui/traits/deep-norm-pending.rs b/tests/ui/traits/deep-norm-pending.rs new file mode 100644 index 0000000000000..f56c3cfa3eab4 --- /dev/null +++ b/tests/ui/traits/deep-norm-pending.rs @@ -0,0 +1,24 @@ +trait Foo { + type Assoc; +} + +trait Bar { + fn method() -> impl Sized; + //~^ ERROR the trait bound `T: Foo` is not satisfied +} +impl Bar for T +//~^ ERROR the trait bound `T: Foo` is not satisfied +//~| ERROR the trait bound `T: Foo` is not satisfied +where + ::Assoc: Sized, +{ + fn method() {} + //~^ ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/deep-norm-pending.stderr b/tests/ui/traits/deep-norm-pending.stderr new file mode 100644 index 0000000000000..b95b9d7f4aec7 --- /dev/null +++ b/tests/ui/traits/deep-norm-pending.stderr @@ -0,0 +1,130 @@ +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:5 + | +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:9:1 + | +LL | / impl Bar for T +LL | | +LL | | +LL | | where +LL | | ::Assoc: Sized, + | |_____________________________^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:9:1 + | +LL | / impl Bar for T +LL | | +LL | | +LL | | where +... | +LL | | } + | |_^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:5 + | +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:5 + | +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | +note: required for `T` to implement `Bar` + --> $DIR/deep-norm-pending.rs:9:9 + | +LL | impl Bar for T + | ^^^ ^ +... +LL | ::Assoc: Sized, + | ----- unsatisfied trait bound introduced here +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:5 + | +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:6:20 + | +LL | fn method() -> impl Sized; + | ^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | +note: required for `T` to implement `Bar` + --> $DIR/deep-norm-pending.rs:9:9 + | +LL | impl Bar for T + | ^^^ ^ +... +LL | ::Assoc: Sized, + | ----- unsatisfied trait bound introduced here +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:5 + | +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:15:8 + | +LL | fn method() {} + | ^^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | ::Assoc: Sized, T: Foo + | ++++++ + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0277`. From dd2d6b222b7a7ad615e612b55fcf3933d4036be3 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Fri, 18 Apr 2025 00:44:11 +0900 Subject: [PATCH 08/10] Cleaned up 5 tests in `tests/ui` --- .../writing-to-immutable-vec.rs | 0 .../writing-to-immutable-vec.stderr | 0 .../{ => deref-patterns}/deref-non-pointer.rs | 0 .../deref-non-pointer.stderr | 0 tests/ui/lazy-and-or.rs | 12 --------- tests/ui/list.rs | 9 ------- tests/ui/minus-string.rs | 1 - tests/ui/or-patterns/lazy-and-or.rs | 25 +++++++++++++++++++ tests/ui/recursion/recursive-enum-box.rs | 21 ++++++++++++++++ tests/ui/typeck/minus-string.rs | 7 ++++++ tests/ui/{ => typeck}/minus-string.stderr | 6 ++--- 11 files changed, 56 insertions(+), 25 deletions(-) rename tests/ui/{ => borrowck}/writing-to-immutable-vec.rs (100%) rename tests/ui/{ => borrowck}/writing-to-immutable-vec.stderr (100%) rename tests/ui/{ => deref-patterns}/deref-non-pointer.rs (100%) rename tests/ui/{ => deref-patterns}/deref-non-pointer.stderr (100%) delete mode 100644 tests/ui/lazy-and-or.rs delete mode 100644 tests/ui/list.rs delete mode 100644 tests/ui/minus-string.rs create mode 100644 tests/ui/or-patterns/lazy-and-or.rs create mode 100644 tests/ui/recursion/recursive-enum-box.rs create mode 100644 tests/ui/typeck/minus-string.rs rename tests/ui/{ => typeck}/minus-string.stderr (69%) diff --git a/tests/ui/writing-to-immutable-vec.rs b/tests/ui/borrowck/writing-to-immutable-vec.rs similarity index 100% rename from tests/ui/writing-to-immutable-vec.rs rename to tests/ui/borrowck/writing-to-immutable-vec.rs diff --git a/tests/ui/writing-to-immutable-vec.stderr b/tests/ui/borrowck/writing-to-immutable-vec.stderr similarity index 100% rename from tests/ui/writing-to-immutable-vec.stderr rename to tests/ui/borrowck/writing-to-immutable-vec.stderr diff --git a/tests/ui/deref-non-pointer.rs b/tests/ui/deref-patterns/deref-non-pointer.rs similarity index 100% rename from tests/ui/deref-non-pointer.rs rename to tests/ui/deref-patterns/deref-non-pointer.rs diff --git a/tests/ui/deref-non-pointer.stderr b/tests/ui/deref-patterns/deref-non-pointer.stderr similarity index 100% rename from tests/ui/deref-non-pointer.stderr rename to tests/ui/deref-patterns/deref-non-pointer.stderr diff --git a/tests/ui/lazy-and-or.rs b/tests/ui/lazy-and-or.rs deleted file mode 100644 index f9dbeb68959a3..0000000000000 --- a/tests/ui/lazy-and-or.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -fn incr(x: &mut isize) -> bool { *x += 1; assert!((false)); return false; } - -pub fn main() { - let x = 1 == 2 || 3 == 3; - assert!((x)); - let mut y: isize = 10; - println!("{}", x || incr(&mut y)); - assert_eq!(y, 10); - if true && x { assert!((true)); } else { assert!((false)); } -} diff --git a/tests/ui/list.rs b/tests/ui/list.rs deleted file mode 100644 index 443c4c9f28f88..0000000000000 --- a/tests/ui/list.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] - -enum list { #[allow(dead_code)] cons(isize, Box), nil, } - -pub fn main() { - list::cons(10, Box::new(list::cons(11, Box::new(list::cons(12, Box::new(list::nil)))))); -} diff --git a/tests/ui/minus-string.rs b/tests/ui/minus-string.rs deleted file mode 100644 index b83347b937edf..0000000000000 --- a/tests/ui/minus-string.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() { -"foo".to_string(); } //~ ERROR cannot apply unary operator `-` to type `String` diff --git a/tests/ui/or-patterns/lazy-and-or.rs b/tests/ui/or-patterns/lazy-and-or.rs new file mode 100644 index 0000000000000..3d69553132b98 --- /dev/null +++ b/tests/ui/or-patterns/lazy-and-or.rs @@ -0,0 +1,25 @@ +//@ run-pass +// This test verifies the short-circuiting behavior of logical operators `||` and `&&`. +// It ensures that the right-hand expression is not evaluated when the left-hand +// expression is sufficient to determine the result. + +fn would_panic_if_called(x: &mut isize) -> bool { + *x += 1; + assert!(false, "This function should never be called due to short-circuiting"); + false +} + +fn main() { + let x = 1 == 2 || 3 == 3; + assert!(x); + + let mut y: isize = 10; + println!("Result of short-circuit: {}", x || would_panic_if_called(&mut y)); + assert_eq!(y, 10, "y should remain 10 if short-circuiting works correctly"); + + if true && x { + assert!(true); + } else { + assert!(false, "This branch should not be reached"); + } +} diff --git a/tests/ui/recursion/recursive-enum-box.rs b/tests/ui/recursion/recursive-enum-box.rs new file mode 100644 index 0000000000000..540b0c553603c --- /dev/null +++ b/tests/ui/recursion/recursive-enum-box.rs @@ -0,0 +1,21 @@ +//@ run-pass +// A smoke test for recursive enum structures using Box. +// This test constructs a linked list-like structure to exercise memory allocation and ownership. +// Originally introduced in 2010, this is one of Rust’s earliest test cases. + +#![allow(dead_code)] + +enum List { + Cons(isize, Box), + Nil, +} + +fn main() { + List::Cons( + 10, + Box::new(List::Cons( + 11, + Box::new(List::Cons(12, Box::new(List::Nil))), + )), + ); +} diff --git a/tests/ui/typeck/minus-string.rs b/tests/ui/typeck/minus-string.rs new file mode 100644 index 0000000000000..1c0f73a37132c --- /dev/null +++ b/tests/ui/typeck/minus-string.rs @@ -0,0 +1,7 @@ +// Regression test for issue #813. +// This ensures that the unary negation operator `-` cannot be applied to an owned `String`. +// Previously, due to a type-checking bug, this was mistakenly accepted by the compiler. + +fn main() { + -"foo".to_string(); //~ ERROR cannot apply unary operator `-` to type `String` +} diff --git a/tests/ui/minus-string.stderr b/tests/ui/typeck/minus-string.stderr similarity index 69% rename from tests/ui/minus-string.stderr rename to tests/ui/typeck/minus-string.stderr index 153965c810ea7..d2ebcd01ff9c1 100644 --- a/tests/ui/minus-string.stderr +++ b/tests/ui/typeck/minus-string.stderr @@ -1,8 +1,8 @@ error[E0600]: cannot apply unary operator `-` to type `String` - --> $DIR/minus-string.rs:1:13 + --> $DIR/minus-string.rs:6:5 | -LL | fn main() { -"foo".to_string(); } - | ^^^^^^^^^^^^^^^^^^ cannot apply unary operator `-` +LL | -"foo".to_string(); + | ^^^^^^^^^^^^^^^^^^ cannot apply unary operator `-` | note: the foreign item type `String` doesn't implement `Neg` --> $SRC_DIR/alloc/src/string.rs:LL:COL From 5e202a3c71f3ae85e773d054922a24c0302e6f72 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Mon, 21 Apr 2025 14:55:06 +0000 Subject: [PATCH 09/10] Use output dir for mir_dump_dir --- src/tools/compiletest/src/runtest.rs | 13 +------------ src/tools/compiletest/src/runtest/mir_opt.rs | 4 ++-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d11f5c1a3a6f4..cc09463c358a7 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1395,14 +1395,6 @@ impl<'test> TestCx<'test> { matches!(self.config.suite.as_str(), "rustdoc-ui" | "rustdoc-js" | "rustdoc-json") } - fn get_mir_dump_dir(&self) -> Utf8PathBuf { - let mut mir_dump_dir = self.config.build_test_suite_root.clone(); - debug!("input_file: {}", self.testpaths.file); - mir_dump_dir.push(&self.testpaths.relative_dir); - mir_dump_dir.push(self.testpaths.file.file_stem().unwrap()); - mir_dump_dir - } - fn make_compile_args( &self, input_file: &Utf8Path, @@ -1511,10 +1503,7 @@ impl<'test> TestCx<'test> { } let set_mir_dump_dir = |rustc: &mut Command| { - let mir_dump_dir = self.get_mir_dump_dir(); - remove_and_create_dir_all(&mir_dump_dir).unwrap_or_else(|e| { - panic!("failed to remove and recreate output directory `{mir_dump_dir}`: {e}") - }); + let mir_dump_dir = self.output_base_dir(); let mut dir_opt = "-Zdump-mir-dir=".to_string(); dir_opt.push_str(mir_dump_dir.as_str()); debug!("dir_opt: {:?}", dir_opt); diff --git a/src/tools/compiletest/src/runtest/mir_opt.rs b/src/tools/compiletest/src/runtest/mir_opt.rs index ded6a68fe5876..efdb131bf14a8 100644 --- a/src/tools/compiletest/src/runtest/mir_opt.rs +++ b/src/tools/compiletest/src/runtest/mir_opt.rs @@ -56,7 +56,7 @@ impl TestCx<'_> { self.diff_mir_files(from_file.into(), after.into()) } else { let mut output_file = Utf8PathBuf::new(); - output_file.push(self.get_mir_dump_dir()); + output_file.push(self.output_base_dir()); output_file.push(&from_file); debug!("comparing the contents of: {} with {:?}", output_file, expected_file); if !output_file.exists() { @@ -100,7 +100,7 @@ impl TestCx<'_> { fn diff_mir_files(&self, before: Utf8PathBuf, after: Utf8PathBuf) -> String { let to_full_path = |path: Utf8PathBuf| { - let full = self.get_mir_dump_dir().join(&path); + let full = self.output_base_dir().join(&path); if !full.exists() { panic!( "the mir dump file for {} does not exist (requested in {})", From 619ed1540a7704afd08ca91b3a7ddece94ba9720 Mon Sep 17 00:00:00 2001 From: blyxyas Date: Mon, 21 Apr 2025 17:36:36 +0200 Subject: [PATCH 10/10] Document why CodeStats::type_sizes is public --- compiler/rustc_session/src/code_stats.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_session/src/code_stats.rs b/compiler/rustc_session/src/code_stats.rs index 6b18d450e9e5e..80603b4a1567f 100644 --- a/compiler/rustc_session/src/code_stats.rs +++ b/compiler/rustc_session/src/code_stats.rs @@ -72,6 +72,8 @@ pub struct TypeSizeInfo { #[derive(Default)] pub struct CodeStats { + /// The hash set that actually holds all the type size information. + /// The field is public for use in external tools. See #139876. pub type_sizes: Lock>, }