Skip to content

Commit 5d707b0

Browse files
committed
Auto merge of #141912 - Kobzol:rollup-wurlnsx, r=Kobzol
Rollup of 5 pull requests Successful merges: - #141767 (ci: use free runner for aarch64-gnu-llvm-19-1 PR job) - #141858 (Fix typo in `StructuralPartialEq` docs) - #141865 (Optionally don't steal the THIR) - #141874 (add f16_epsilon and f128_epsilon diagnostic items) - #141904 (test-float-parse: apply `cfg(not(bootstrap))`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 449c801 + 44ba243 commit 5d707b0

File tree

12 files changed

+33
-6
lines changed

12 files changed

+33
-6
lines changed

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ fn test_unstable_options_tracking_hash() {
715715
untracked!(no_analysis, true);
716716
untracked!(no_leak_check, true);
717717
untracked!(no_parallel_backend, true);
718+
untracked!(no_steal_thir, true);
718719
untracked!(parse_crate_root_only, true);
719720
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
720721
untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ rustc_queries! {
535535
separate_provide_extern
536536
}
537537

538-
/// Fetch the THIR for a given body.
538+
/// Fetch the THIR for a given body. The THIR body gets stolen by unsafety checking unless
539+
/// `-Zno-steal-thir` is on.
539540
query thir_body(key: LocalDefId) -> Result<(&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId), ErrorGuaranteed> {
540541
// Perf tests revealed that hashing THIR is inefficient (see #85729).
541542
no_hash

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,14 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
201201
/// Handle closures/coroutines/inline-consts, which is unsafecked with their parent body.
202202
fn visit_inner_body(&mut self, def: LocalDefId) {
203203
if let Ok((inner_thir, expr)) = self.tcx.thir_body(def) {
204-
// Runs all other queries that depend on THIR.
204+
// Run all other queries that depend on THIR.
205205
self.tcx.ensure_done().mir_built(def);
206-
let inner_thir = &inner_thir.steal();
206+
let inner_thir = if self.tcx.sess.opts.unstable_opts.no_steal_thir {
207+
&inner_thir.borrow()
208+
} else {
209+
// We don't have other use for the THIR. Steal it to reduce memory usage.
210+
&inner_thir.steal()
211+
};
207212
let hir_context = self.tcx.local_def_id_to_hir_id(def);
208213
let safety_context = mem::replace(&mut self.safety_context, SafetyContext::Safe);
209214
let mut inner_visitor = UnsafetyVisitor {
@@ -1157,7 +1162,12 @@ pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
11571162
let Ok((thir, expr)) = tcx.thir_body(def) else { return };
11581163
// Runs all other queries that depend on THIR.
11591164
tcx.ensure_done().mir_built(def);
1160-
let thir = &thir.steal();
1165+
let thir = if tcx.sess.opts.unstable_opts.no_steal_thir {
1166+
&thir.borrow()
1167+
} else {
1168+
// We don't have other use for the THIR. Steal it to reduce memory usage.
1169+
&thir.steal()
1170+
};
11611171

11621172
let hir_id = tcx.local_def_id_to_hir_id(def);
11631173
let safety_context = tcx.hir_fn_sig_by_hir_id(hir_id).map_or(SafetyContext::Safe, |fn_sig| {

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,8 @@ options! {
23662366
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
23672367
no_profiler_runtime: bool = (false, parse_no_value, [TRACKED],
23682368
"prevent automatic injection of the profiler_builtins crate"),
2369+
no_steal_thir: bool = (false, parse_bool, [UNTRACKED],
2370+
"don't steal the THIR when we're done with it; useful for rustc drivers (default: no)"),
23692371
no_trait_vptr: bool = (false, parse_no_value, [TRACKED],
23702372
"disable generation of trait vptr in vtable for upcasting"),
23712373
no_unique_section_names: bool = (false, parse_bool, [TRACKED],

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,10 @@ symbols! {
937937
external_doc,
938938
f,
939939
f128,
940+
f128_epsilon,
940941
f128_nan,
941942
f16,
943+
f16_epsilon,
942944
f16_nan,
943945
f16c_target_feature,
944946
f32,

library/core/src/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub trait Unsize<T: ?Sized> {
200200
///
201201
/// Constants are only allowed as patterns if (a) their type implements
202202
/// `PartialEq`, and (b) interpreting the value of the constant as a pattern
203-
/// is equialent to calling `PartialEq`. This ensures that constants used as
203+
/// is equivalent to calling `PartialEq`. This ensures that constants used as
204204
/// patterns cannot expose implementation details in an unexpected way or
205205
/// cause semver hazards.
206206
///

library/core/src/num/f128.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl f128 {
171171
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
172172
/// [`MANTISSA_DIGITS`]: f128::MANTISSA_DIGITS
173173
#[unstable(feature = "f128", issue = "116909")]
174+
#[rustc_diagnostic_item = "f128_epsilon"]
174175
pub const EPSILON: f128 = 1.92592994438723585305597794258492732e-34_f128;
175176

176177
/// Smallest finite `f128` value.

library/core/src/num/f16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ impl f16 {
168168
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
169169
/// [`MANTISSA_DIGITS`]: f16::MANTISSA_DIGITS
170170
#[unstable(feature = "f16", issue = "116909")]
171+
#[rustc_diagnostic_item = "f16_epsilon"]
171172
pub const EPSILON: f16 = 9.7656e-4_f16;
172173

173174
/// Smallest finite `f16` value.

src/ci/github-actions/jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pr:
127127
env:
128128
IMAGE: aarch64-gnu-llvm-19
129129
DOCKER_SCRIPT: stage_2_test_set1.sh
130-
<<: *job-aarch64-linux-8c
130+
<<: *job-aarch64-linux
131131
- name: aarch64-gnu-llvm-19-2
132132
env:
133133
IMAGE: aarch64-gnu-llvm-19
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `no-steal-thir`
2+
3+
By default, to save on memory, the THIR body (obtained from the `tcx.thir_body` query) is stolen
4+
once no longer used. This is inconvenient for authors of rustc drivers who want to access the THIR.
5+
6+
This option disables the stealing. This has no observable effect on compiler behavior, only on
7+
memory usage.

src/etc/test-float-parse/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub fn register_tests(cfg: &Config) -> Vec<TestInfo> {
119119

120120
// Register normal generators for all floats.
121121

122+
#[cfg(not(bootstrap))]
122123
#[cfg(target_has_reliable_f16)]
123124
register_float::<f16>(&mut tests, cfg);
124125
register_float::<f32>(&mut tests, cfg);

src/etc/test-float-parse/src/traits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ macro_rules! impl_float {
170170

171171
impl_float!(f32, u32; f64, u64);
172172

173+
#[cfg(not(bootstrap))]
173174
#[cfg(target_has_reliable_f16)]
174175
impl_float!(f16, u16);
175176

0 commit comments

Comments
 (0)