Skip to content

Commit 8f2819b

Browse files
committed
Auto merge of rust-lang#140122 - ChrisDenton:rollup-qsj6xu0, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - rust-lang#139946 (fix missing word in comment) - rust-lang#139982 (SystemTime doc tweaks) - rust-lang#140009 (docs(LocalKey<T>): clarify that T's Drop shouldn't panic) - rust-lang#140021 (Don't ICE on pending obligations from deep normalization in a loop) - rust-lang#140029 (Relocate tests in `tests/ui`) - rust-lang#140030 (Fix autodiff debug builds) - rust-lang#140120 (Use `output_base_dir` for `mir_dump_dir`) - rust-lang#140121 (Document why CodeStats::type_sizes is public) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c8f9423 + 77325f5 commit 8f2819b

File tree

26 files changed

+240
-63
lines changed

26 files changed

+240
-63
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ where
254254
always_export_generics,
255255
);
256256

257-
// We can't differentiate something that got inlined.
257+
// We can't differentiate a function that got inlined.
258258
let autodiff_active = cfg!(llvm_enzyme)
259+
&& matches!(mono_item, MonoItem::Fn(_))
259260
&& cx
260261
.tcx
261262
.codegen_fn_attrs(mono_item.def_id())

compiler/rustc_session/src/code_stats.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub struct TypeSizeInfo {
7272

7373
#[derive(Default)]
7474
pub struct CodeStats {
75+
/// The hash set that actually holds all the type size information.
76+
/// The field is public for use in external tools. See #139876.
7577
pub type_sizes: Lock<FxHashSet<TypeSizeInfo>>,
7678
}
7779

compiler/rustc_trait_selection/src/traits/normalize.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ impl<'tcx> At<'_, 'tcx> {
7777
.into_value_registering_obligations(self.infcx, &mut *fulfill_cx);
7878
let errors = fulfill_cx.select_all_or_error(self.infcx);
7979
let value = self.infcx.resolve_vars_if_possible(value);
80-
if errors.is_empty() { Ok(value) } else { Err(errors) }
80+
if errors.is_empty() {
81+
Ok(value)
82+
} else {
83+
// Drop pending obligations, since deep normalization may happen
84+
// in a loop and we don't want to trigger the assertion on the next
85+
// iteration due to pending ambiguous obligations we've left over.
86+
let _ = fulfill_cx.collect_remaining_errors(self.infcx);
87+
Err(errors)
88+
}
8189
}
8290
}
8391
}

library/core/src/any.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ impl hash::Hash for TypeId {
772772
// (especially given the previous point about the lower 64 bits being
773773
// high quality on their own).
774774
// - It is correct to do so -- only hashing a subset of `self` is still
775-
// with an `Eq` implementation that considers the entire value, as
776-
// ours does.
775+
// compatible with an `Eq` implementation that considers the entire
776+
// value, as ours does.
777777
self.t.1.hash(state);
778778
}
779779
}

library/std/src/rt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! rtprintpanic {
4646
macro_rules! rtabort {
4747
($($t:tt)*) => {
4848
{
49-
rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
49+
rtprintpanic!("fatal runtime error: {}, aborting\n", format_args!($($t)*));
5050
crate::sys::abort_internal();
5151
}
5252
}

library/std/src/thread/local.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ use crate::fmt;
2222
///
2323
/// Initialization is dynamically performed on the first call to a setter (e.g.
2424
/// [`with`]) within a thread, and values that implement [`Drop`] get
25-
/// destructed when a thread exits. Some caveats apply, which are explained below.
25+
/// destructed when a thread exits. Some platform-specific caveats apply, which
26+
/// are explained below.
27+
/// Note that, should the destructor panics, the whole process will be [aborted].
2628
///
2729
/// A `LocalKey`'s initializer cannot recursively depend on itself. Using a
2830
/// `LocalKey` in this way may cause panics, aborts or infinite recursion on
2931
/// the first call to `with`.
3032
///
33+
/// [aborted]: crate::process::abort
34+
///
3135
/// # Single-thread Synchronization
3236
///
3337
/// Though there is no potential race with other threads, it is still possible to

library/std/src/time.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ pub struct Instant(time::Instant);
205205
/// println!("{}", elapsed.as_secs());
206206
/// }
207207
/// Err(e) => {
208-
/// // an error occurred!
209-
/// println!("Error: {e:?}");
208+
/// // the system clock went backwards!
209+
/// println!("Great Scott! {e:?}");
210210
/// }
211211
/// }
212212
/// }
@@ -245,6 +245,7 @@ pub struct Instant(time::Instant);
245245
/// > structure cannot represent the new point in time.
246246
///
247247
/// [`add`]: SystemTime::add
248+
/// [`UNIX_EPOCH`]: SystemTime::UNIX_EPOCH
248249
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
249250
#[stable(feature = "time2", since = "1.8.0")]
250251
pub struct SystemTime(time::SystemTime);

src/tools/compiletest/src/runtest.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1395,14 +1395,6 @@ impl<'test> TestCx<'test> {
13951395
matches!(self.config.suite.as_str(), "rustdoc-ui" | "rustdoc-js" | "rustdoc-json")
13961396
}
13971397

1398-
fn get_mir_dump_dir(&self) -> Utf8PathBuf {
1399-
let mut mir_dump_dir = self.config.build_test_suite_root.clone();
1400-
debug!("input_file: {}", self.testpaths.file);
1401-
mir_dump_dir.push(&self.testpaths.relative_dir);
1402-
mir_dump_dir.push(self.testpaths.file.file_stem().unwrap());
1403-
mir_dump_dir
1404-
}
1405-
14061398
fn make_compile_args(
14071399
&self,
14081400
input_file: &Utf8Path,
@@ -1511,10 +1503,7 @@ impl<'test> TestCx<'test> {
15111503
}
15121504

15131505
let set_mir_dump_dir = |rustc: &mut Command| {
1514-
let mir_dump_dir = self.get_mir_dump_dir();
1515-
remove_and_create_dir_all(&mir_dump_dir).unwrap_or_else(|e| {
1516-
panic!("failed to remove and recreate output directory `{mir_dump_dir}`: {e}")
1517-
});
1506+
let mir_dump_dir = self.output_base_dir();
15181507
let mut dir_opt = "-Zdump-mir-dir=".to_string();
15191508
dir_opt.push_str(mir_dump_dir.as_str());
15201509
debug!("dir_opt: {:?}", dir_opt);

src/tools/compiletest/src/runtest/mir_opt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl TestCx<'_> {
5656
self.diff_mir_files(from_file.into(), after.into())
5757
} else {
5858
let mut output_file = Utf8PathBuf::new();
59-
output_file.push(self.get_mir_dump_dir());
59+
output_file.push(self.output_base_dir());
6060
output_file.push(&from_file);
6161
debug!("comparing the contents of: {} with {:?}", output_file, expected_file);
6262
if !output_file.exists() {
@@ -100,7 +100,7 @@ impl TestCx<'_> {
100100

101101
fn diff_mir_files(&self, before: Utf8PathBuf, after: Utf8PathBuf) -> String {
102102
let to_full_path = |path: Utf8PathBuf| {
103-
let full = self.get_mir_dump_dir().join(&path);
103+
let full = self.output_base_dir().join(&path);
104104
if !full.exists() {
105105
panic!(
106106
"the mir dump file for {} does not exist (requested in {})",

src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
thread $NAME panicked at tests/fail/panic/tls_macro_const_drop_panic.rs:LL:CC:
33
ow
4-
fatal runtime error: thread local panicked on drop
4+
fatal runtime error: thread local panicked on drop, aborting
55
error: abnormal termination: the program aborted execution
66

77
error: aborting due to 1 previous error

src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
thread $NAME panicked at tests/fail/panic/tls_macro_drop_panic.rs:LL:CC:
33
ow
4-
fatal runtime error: thread local panicked on drop
4+
fatal runtime error: thread local panicked on drop, aborting
55
error: abnormal termination: the program aborted execution
66

77
error: aborting due to 1 previous error

tests/crashes/133868.rs

-13
This file was deleted.

tests/ui/lazy-and-or.rs

-12
This file was deleted.

tests/ui/list.rs

-9
This file was deleted.

tests/ui/minus-string.rs

-1
This file was deleted.

tests/ui/or-patterns/lazy-and-or.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ run-pass
2+
// This test verifies the short-circuiting behavior of logical operators `||` and `&&`.
3+
// It ensures that the right-hand expression is not evaluated when the left-hand
4+
// expression is sufficient to determine the result.
5+
6+
fn would_panic_if_called(x: &mut isize) -> bool {
7+
*x += 1;
8+
assert!(false, "This function should never be called due to short-circuiting");
9+
false
10+
}
11+
12+
fn main() {
13+
let x = 1 == 2 || 3 == 3;
14+
assert!(x);
15+
16+
let mut y: isize = 10;
17+
println!("Result of short-circuit: {}", x || would_panic_if_called(&mut y));
18+
assert_eq!(y, 10, "y should remain 10 if short-circuiting works correctly");
19+
20+
if true && x {
21+
assert!(true);
22+
} else {
23+
assert!(false, "This branch should not be reached");
24+
}
25+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ run-pass
2+
// A smoke test for recursive enum structures using Box<T>.
3+
// This test constructs a linked list-like structure to exercise memory allocation and ownership.
4+
// Originally introduced in 2010, this is one of Rust’s earliest test cases.
5+
6+
#![allow(dead_code)]
7+
8+
enum List {
9+
Cons(isize, Box<List>),
10+
Nil,
11+
}
12+
13+
fn main() {
14+
List::Cons(
15+
10,
16+
Box::new(List::Cons(
17+
11,
18+
Box::new(List::Cons(12, Box::new(List::Nil))),
19+
)),
20+
);
21+
}

tests/ui/runtime/rt-explody-panic-payloads.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fn main() {
2727
// by QEMU in the stderr whenever a core dump happens. Remove it before the check.
2828
v.strip_suffix("qemu: uncaught target signal 6 (Aborted) - core dumped\n").unwrap_or(v)
2929
})
30-
.map(|v| { v.ends_with("fatal runtime error: drop of the panic payload panicked\n") })
30+
.map(|v| v.ends_with("fatal runtime error: drop of the panic payload panicked, aborting\n"))
3131
.unwrap_or(false));
3232
}

tests/ui/traits/deep-norm-pending.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
trait Foo {
2+
type Assoc;
3+
}
4+
5+
trait Bar {
6+
fn method() -> impl Sized;
7+
//~^ ERROR the trait bound `T: Foo` is not satisfied
8+
}
9+
impl<T> Bar for T
10+
//~^ ERROR the trait bound `T: Foo` is not satisfied
11+
//~| ERROR the trait bound `T: Foo` is not satisfied
12+
where
13+
<T as Foo>::Assoc: Sized,
14+
{
15+
fn method() {}
16+
//~^ ERROR the trait bound `T: Foo` is not satisfied
17+
//~| ERROR the trait bound `T: Foo` is not satisfied
18+
//~| ERROR the trait bound `T: Foo` is not satisfied
19+
//~| ERROR the trait bound `T: Foo` is not satisfied
20+
//~| ERROR the trait bound `T: Foo` is not satisfied
21+
//~| ERROR the trait bound `T: Foo` is not satisfied
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)