Skip to content

Commit a1d7676

Browse files
committed
Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmease
Rollup of 9 pull requests Successful merges: - #136121 (Deduplicate operand creation between scalars, non-scalars and string patterns) - #136134 (Fix SIMD codegen tests on LLVM 20) - #136153 (Locate asan-odr-win with other sanitizer tests) - #136161 (rustdoc: add nobuild typescript checking to our JS) - #136166 (interpret: is_alloc_live: check global allocs last) - #136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items) - #136170 (Reject unsound toggling of Arm atomics-32 target feature) - #136176 (Render pattern types nicely in mir dumps) - #136186 (uefi: process: Fix args) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 61cc3e5 + 7e60f27 commit a1d7676

30 files changed

+1812
-755
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
830830
/// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is
831831
/// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics.
832832
pub fn is_alloc_live(&self, id: AllocId) -> bool {
833-
self.tcx.try_get_global_alloc(id).is_some()
834-
|| self.memory.alloc_map.contains_key_ref(&id)
833+
self.memory.alloc_map.contains_key_ref(&id)
835834
|| self.memory.extra_fn_ptr_map.contains_key(&id)
835+
// We check `tcx` last as that has to acquire a lock in `many-seeds` mode.
836+
// This also matches the order in `get_alloc_info`.
837+
|| self.tcx.try_get_global_alloc(id).is_some()
836838
}
837839

838840
/// Obtain the size and alignment of an allocation, even if that allocation has

compiler/rustc_middle/src/ty/print/pretty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
17401740
" as ",
17411741
)?;
17421742
}
1743+
ty::Pat(base_ty, pat) => {
1744+
self.pretty_print_const_scalar_int(int, *base_ty, print_ty)?;
1745+
p!(write(" is {pat:?}"));
1746+
}
17431747
// Nontrivial types with scalar bit representation
17441748
_ => {
17451749
let print = |this: &mut Self| {

compiler/rustc_mir_build/src/builder/matches/test.rs

+50-49
Original file line numberDiff line numberDiff line change
@@ -141,66 +141,71 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
141141
self.cfg.terminate(block, self.source_info(match_start_span), terminator);
142142
}
143143

144-
TestKind::Eq { value, ty } => {
144+
TestKind::Eq { value, mut ty } => {
145145
let tcx = self.tcx;
146146
let success_block = target_block(TestBranch::Success);
147147
let fail_block = target_block(TestBranch::Failure);
148-
if let ty::Adt(def, _) = ty.kind()
149-
&& tcx.is_lang_item(def.did(), LangItem::String)
150-
{
151-
if !tcx.features().string_deref_patterns() {
152-
span_bug!(
148+
149+
let expect_ty = value.ty();
150+
let expect = self.literal_operand(test.span, value);
151+
152+
let mut place = place;
153+
let mut block = block;
154+
match ty.kind() {
155+
ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::String) => {
156+
if !tcx.features().string_deref_patterns() {
157+
span_bug!(
158+
test.span,
159+
"matching on `String` went through without enabling string_deref_patterns"
160+
);
161+
}
162+
let re_erased = tcx.lifetimes.re_erased;
163+
let ref_str_ty = Ty::new_imm_ref(tcx, re_erased, tcx.types.str_);
164+
let ref_str = self.temp(ref_str_ty, test.span);
165+
let eq_block = self.cfg.start_new_block();
166+
// `let ref_str: &str = <String as Deref>::deref(&place);`
167+
self.call_deref(
168+
block,
169+
eq_block,
170+
place,
171+
Mutability::Not,
172+
ty,
173+
ref_str,
153174
test.span,
154-
"matching on `String` went through without enabling string_deref_patterns"
155175
);
176+
// Since we generated a `ref_str = <String as Deref>::deref(&place) -> eq_block` terminator,
177+
// we need to add all further statements to `eq_block`.
178+
// Similarly, the normal test code should be generated for the `&str`, instead of the `String`.
179+
block = eq_block;
180+
place = ref_str;
181+
ty = ref_str_ty;
156182
}
157-
let re_erased = tcx.lifetimes.re_erased;
158-
let ref_str_ty = Ty::new_imm_ref(tcx, re_erased, tcx.types.str_);
159-
let ref_str = self.temp(ref_str_ty, test.span);
160-
let eq_block = self.cfg.start_new_block();
161-
// `let ref_str: &str = <String as Deref>::deref(&place);`
162-
self.call_deref(
163-
block,
164-
eq_block,
165-
place,
166-
Mutability::Not,
167-
ty,
168-
ref_str,
169-
test.span,
170-
);
171-
self.non_scalar_compare(
172-
eq_block,
173-
success_block,
174-
fail_block,
175-
source_info,
176-
value,
177-
ref_str,
178-
ref_str_ty,
179-
);
180-
} else if !ty.is_scalar() {
183+
_ => {}
184+
}
185+
186+
if !ty.is_scalar() {
181187
// Use `PartialEq::eq` instead of `BinOp::Eq`
182188
// (the binop can only handle primitives)
183189
self.non_scalar_compare(
184190
block,
185191
success_block,
186192
fail_block,
187193
source_info,
188-
value,
189-
place,
194+
expect,
195+
expect_ty,
196+
Operand::Copy(place),
190197
ty,
191198
);
192199
} else {
193-
assert_eq!(value.ty(), ty);
194-
let expect = self.literal_operand(test.span, value);
195-
let val = Operand::Copy(place);
200+
assert_eq!(expect_ty, ty);
196201
self.compare(
197202
block,
198203
success_block,
199204
fail_block,
200205
source_info,
201206
BinOp::Eq,
202207
expect,
203-
val,
208+
Operand::Copy(place),
204209
);
205210
}
206211
}
@@ -371,12 +376,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
371376
success_block: BasicBlock,
372377
fail_block: BasicBlock,
373378
source_info: SourceInfo,
374-
value: Const<'tcx>,
375-
mut val: Place<'tcx>,
379+
mut expect: Operand<'tcx>,
380+
expect_ty: Ty<'tcx>,
381+
mut val: Operand<'tcx>,
376382
mut ty: Ty<'tcx>,
377383
) {
378-
let mut expect = self.literal_operand(source_info.span, value);
379-
380384
// If we're using `b"..."` as a pattern, we need to insert an
381385
// unsizing coercion, as the byte string has the type `&[u8; N]`.
382386
//
@@ -391,7 +395,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
391395
_ => None,
392396
};
393397
let opt_ref_ty = unsize(ty);
394-
let opt_ref_test_ty = unsize(value.ty());
398+
let opt_ref_test_ty = unsize(expect_ty);
395399
match (opt_ref_ty, opt_ref_test_ty) {
396400
// nothing to do, neither is an array
397401
(None, None) => {}
@@ -410,11 +414,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
410414
PointerCoercion::Unsize,
411415
CoercionSource::Implicit,
412416
),
413-
Operand::Copy(val),
417+
val,
414418
ty,
415419
),
416420
);
417-
val = temp;
421+
val = Operand::Copy(temp);
418422
}
419423
if opt_ref_test_ty.is_some() {
420424
let slice = self.temp(ty, source_info.span);
@@ -470,11 +474,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
470474

471475
const_: method,
472476
})),
473-
args: [Spanned { node: Operand::Copy(val), span: DUMMY_SP }, Spanned {
474-
node: expect,
475-
span: DUMMY_SP,
476-
}]
477-
.into(),
477+
args: [Spanned { node: val, span: DUMMY_SP }, Spanned { node: expect, span: DUMMY_SP }]
478+
.into(),
478479
destination: eq_result,
479480
target: Some(eq_block),
480481
unwind: UnwindAction::Continue,

compiler/rustc_monomorphize/src/collector.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1454,11 +1454,14 @@ impl<'v> RootCollector<'_, 'v> {
14541454
self.output.push(dummy_spanned(MonoItem::Static(def_id)));
14551455
}
14561456
DefKind::Const => {
1457-
// const items only generate mono items if they are
1458-
// actually used somewhere. Just declaring them is insufficient.
1457+
// Const items only generate mono items if they are actually used somewhere.
1458+
// Just declaring them is insufficient.
14591459

1460-
// but even just declaring them must collect the items they refer to
1461-
if let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id()) {
1460+
// But even just declaring them must collect the items they refer to
1461+
// unless their generics require monomorphization.
1462+
if !self.tcx.generics_of(id.owner_id).requires_monomorphization(self.tcx)
1463+
&& let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id())
1464+
{
14621465
collect_const_value(self.tcx, val, self.output);
14631466
}
14641467
}

compiler/rustc_target/src/target_features.rs

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
135135
// tidy-alphabetical-start
136136
("aclass", Unstable(sym::arm_target_feature), &[]),
137137
("aes", Unstable(sym::arm_target_feature), &["neon"]),
138+
(
139+
"atomics-32",
140+
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
141+
&[],
142+
),
138143
("crc", Unstable(sym::arm_target_feature), &[]),
139144
("d32", Unstable(sym::arm_target_feature), &[]),
140145
("dotprod", Unstable(sym::arm_target_feature), &["neon"]),

library/std/src/sys/pal/uefi/process.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ mod uefi_command_internal {
460460
helpers::open_protocol(self.handle, loaded_image::PROTOCOL_GUID).unwrap();
461461

462462
let len = args.len();
463-
let args_size: u32 = crate::mem::size_of_val(&args).try_into().unwrap();
463+
let args_size: u32 = (len * crate::mem::size_of::<u16>()).try_into().unwrap();
464464
let ptr = Box::into_raw(args).as_mut_ptr();
465465

466466
unsafe {
@@ -706,9 +706,10 @@ mod uefi_command_internal {
706706
res.push(QUOTE);
707707
res.extend(prog.encode_wide());
708708
res.push(QUOTE);
709-
res.push(SPACE);
710709

711710
for arg in args {
711+
res.push(SPACE);
712+
712713
// Wrap the argument in quotes to be treat as single arg
713714
res.push(QUOTE);
714715
for c in arg.encode_wide() {
@@ -719,8 +720,6 @@ mod uefi_command_internal {
719720
res.push(c);
720721
}
721722
res.push(QUOTE);
722-
723-
res.push(SPACE);
724723
}
725724

726725
res.into_boxed_slice()

src/ci/docker/host-x86_64/mingw-check/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ENV PATH="/node/bin:${PATH}"
2929

3030
# Install es-check
3131
# Pin its version to prevent unrelated CI failures due to future es-check versions.
32-
RUN npm install es-check@6.1.1 eslint@8.6.0 -g
32+
RUN npm install es-check@6.1.1 eslint@8.6.0 typescript@5.7.3 -g
3333

3434
COPY scripts/sccache.sh /scripts/
3535
RUN sh /scripts/sccache.sh
@@ -68,4 +68,5 @@ ENV SCRIPT \
6868
es-check es2019 ../src/librustdoc/html/static/js/*.js && \
6969
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
7070
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js && \
71-
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js
71+
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js && \
72+
tsc --project ../src/librustdoc/html/static/js/tsconfig.json

src/librustdoc/html/static/js/README.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
These JavaScript files are incorporated into the rustdoc binary at build time,
44
and are minified and written to the filesystem as part of the doc build process.
55

6-
We use the [Closure Compiler](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler)
6+
We use the [TypeScript Compiler](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html)
77
dialect of JSDoc to comment our code and annotate params and return types.
88
To run a check:
99

10-
./x.py doc library/std
11-
npm i -g google-closure-compiler
12-
google-closure-compiler -W VERBOSE \
13-
build/<YOUR PLATFORM>/doc/{search-index*.js,crates*.js} \
14-
src/librustdoc/html/static/js/{search.js,main.js,storage.js} \
15-
--externs src/librustdoc/html/static/js/externs.js >/dev/null
10+
npm i -g typescript
11+
tsc --project tsconfig.json

0 commit comments

Comments
 (0)