Skip to content

Rollup of 8 pull requests #140122

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

Merged
merged 18 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
abf401d
fix missing word in comment
mumbleskates Apr 17, 2025
88bd191
Point UNIX_EPOCH to associated constant in SystemTime docs
coolreader18 Apr 17, 2025
34573d6
Be more specific about the error in the SystemTime example
coolreader18 Apr 17, 2025
0d56e3e
LocalKey<T>: document that the dtor should not panic
ShE3py Apr 18, 2025
17b7d63
rtprintpanic: clarify that the error is aborting the process
ShE3py Apr 18, 2025
b3739f3
Only consider MonoItem::Fn when preventing inlining for autodiff sour…
ZuseZ4 Apr 19, 2025
47911eb
Don't ICE on pending obligations from deep normalization in a loop
compiler-errors Apr 18, 2025
dd2d6b2
Cleaned up 5 tests in `tests/ui`
reddevilmidzy Apr 17, 2025
5e202a3
Use output dir for mir_dump_dir
ChrisDenton Apr 21, 2025
619ed15
Document why CodeStats::type_sizes is public
blyxyas Apr 21, 2025
6925d2f
Rollup merge of #139946 - mumbleskates:any-fix-missing-word, r=jhpratt
ChrisDenton Apr 21, 2025
10e17dc
Rollup merge of #139982 - coolreader18:time-doc-tweak, r=jhpratt
ChrisDenton Apr 21, 2025
24bd564
Rollup merge of #140009 - ShE3py:tls-abort, r=thomcc
ChrisDenton Apr 21, 2025
f79eef9
Rollup merge of #140021 - compiler-errors:no-deep-norm-ice, r=lcnr
ChrisDenton Apr 21, 2025
f8c67c6
Rollup merge of #140029 - reddevilmidzy:move-test, r=jieyouxu
ChrisDenton Apr 21, 2025
c43b82f
Rollup merge of #140030 - EnzymeAD:autodiff-debug, r=jieyouxu
ChrisDenton Apr 21, 2025
280aa4a
Rollup merge of #140120 - ChrisDenton:mir-opt-dump-rev, r=jieyouxu
ChrisDenton Apr 21, 2025
77325f5
Rollup merge of #140121 - blyxyas:code_stats_pub_docs, r=jieyouxu
ChrisDenton Apr 21, 2025
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
3 changes: 2 additions & 1 deletion compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/code_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FxHashSet<TypeSizeInfo>>,
}

Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_trait_selection/src/traits/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
6 changes: 5 additions & 1 deletion library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
/// }
/// }
/// }
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 1 addition & 12 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest/mir_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {})",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 0 additions & 13 deletions tests/crashes/133868.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/lazy-and-or.rs

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ui/list.rs

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/minus-string.rs

This file was deleted.

25 changes: 25 additions & 0 deletions tests/ui/or-patterns/lazy-and-or.rs
Original file line number Diff line number Diff line change
@@ -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");
}
}
21 changes: 21 additions & 0 deletions tests/ui/recursion/recursive-enum-box.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ run-pass
// A smoke test for recursive enum structures using Box<T>.
// 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<List>),
Nil,
}

fn main() {
List::Cons(
10,
Box::new(List::Cons(
11,
Box::new(List::Cons(12, Box::new(List::Nil))),
)),
);
}
2 changes: 1 addition & 1 deletion tests/ui/runtime/rt-explody-panic-payloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
24 changes: 24 additions & 0 deletions tests/ui/traits/deep-norm-pending.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
trait Foo {
type Assoc;
}

trait Bar {
fn method() -> impl Sized;
//~^ ERROR the trait bound `T: Foo` is not satisfied
}
impl<T> Bar for T
//~^ ERROR the trait bound `T: Foo` is not satisfied
//~| ERROR the trait bound `T: Foo` is not satisfied
where
<T as Foo>::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() {}
Loading
Loading