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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 9 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 1 addition & 12 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)