Skip to content
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

Rollup of 9 pull requests #136227

Merged
merged 21 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a9213c2
Deduplicate operand creation between scalars, non-scalars and string …
oli-obk Jan 27, 2025
e1e2e17
Use an operand instead of a place that is always turned into an operand
oli-obk Jan 27, 2025
f895e31
Fix SIMD codegen tests on LLVM 20
nikic Jan 27, 2025
fa4589b
Locate asan-odr-win with other sanitizer tests
tmiasko Jan 23, 2025
bc135aa
interpret: is_alloc_live: check global allocs last
RalfJung Jan 28, 2025
d94b64d
rustdoc: add nobuild typescript checking to our JS
notriddle Jan 13, 2025
0a9ee02
GCI: Don't try to collect mono items inside overly generic free const…
fmease Jan 28, 2025
7f83f8a
Reject unsound toggling of Arm atomics-32 target feature
taiki-e Jan 28, 2025
7877d86
Add mir-opt pattern type tests
oli-obk Jan 28, 2025
fd6713f
Make mir dumps more readable
oli-obk Jan 27, 2025
d62f885
Edit the inputs to const == val check instead of duplicating logic
oli-obk Jan 27, 2025
9c4fd25
uefi: process: Fix args
Ayush1325 Jan 28, 2025
8d183d2
Rollup merge of #136121 - oli-obk:push-zzvxlynmnqpp, r=estebank
fmease Jan 29, 2025
01f1dab
Rollup merge of #136134 - nikic:llvm-20-simd-tests, r=Urgau
fmease Jan 29, 2025
dbc204d
Rollup merge of #136153 - tmiasko:mv-asan-test, r=lqd
fmease Jan 29, 2025
3cc6ea2
Rollup merge of #136161 - notriddle:typescript, r=GuillaumeGomez
fmease Jan 29, 2025
bde47b7
Rollup merge of #136166 - RalfJung:interpet-is-alloc-live, r=compiler…
fmease Jan 29, 2025
e37b744
Rollup merge of #136168 - fmease:gci-fix-mono, r=compiler-errors
fmease Jan 29, 2025
0b1d717
Rollup merge of #136170 - taiki-e:atomics-32, r=workingjubilee
fmease Jan 29, 2025
f49ad60
Rollup merge of #136176 - oli-obk:pattern-type-mir-opts, r=compiler-e…
fmease Jan 29, 2025
7e60f27
Rollup merge of #136186 - Ayush1325:uefi-process-args-fix, r=nicholas…
fmease Jan 29, 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
6 changes: 4 additions & 2 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is
/// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics.
pub fn is_alloc_live(&self, id: AllocId) -> bool {
self.tcx.try_get_global_alloc(id).is_some()
|| self.memory.alloc_map.contains_key_ref(&id)
self.memory.alloc_map.contains_key_ref(&id)
|| self.memory.extra_fn_ptr_map.contains_key(&id)
// We check `tcx` last as that has to acquire a lock in `many-seeds` mode.
// This also matches the order in `get_alloc_info`.
|| self.tcx.try_get_global_alloc(id).is_some()
}

/// Obtain the size and alignment of an allocation, even if that allocation has
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
" as ",
)?;
}
ty::Pat(base_ty, pat) => {
self.pretty_print_const_scalar_int(int, *base_ty, print_ty)?;
p!(write(" is {pat:?}"));
}
// Nontrivial types with scalar bit representation
_ => {
let print = |this: &mut Self| {
Expand Down
99 changes: 50 additions & 49 deletions compiler/rustc_mir_build/src/builder/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,66 +141,71 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.cfg.terminate(block, self.source_info(match_start_span), terminator);
}

TestKind::Eq { value, ty } => {
TestKind::Eq { value, mut ty } => {
let tcx = self.tcx;
let success_block = target_block(TestBranch::Success);
let fail_block = target_block(TestBranch::Failure);
if let ty::Adt(def, _) = ty.kind()
&& tcx.is_lang_item(def.did(), LangItem::String)
{
if !tcx.features().string_deref_patterns() {
span_bug!(

let expect_ty = value.ty();
let expect = self.literal_operand(test.span, value);

let mut place = place;
let mut block = block;
match ty.kind() {
ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::String) => {
if !tcx.features().string_deref_patterns() {
span_bug!(
test.span,
"matching on `String` went through without enabling string_deref_patterns"
);
}
let re_erased = tcx.lifetimes.re_erased;
let ref_str_ty = Ty::new_imm_ref(tcx, re_erased, tcx.types.str_);
let ref_str = self.temp(ref_str_ty, test.span);
let eq_block = self.cfg.start_new_block();
// `let ref_str: &str = <String as Deref>::deref(&place);`
self.call_deref(
block,
eq_block,
place,
Mutability::Not,
ty,
ref_str,
test.span,
"matching on `String` went through without enabling string_deref_patterns"
);
// Since we generated a `ref_str = <String as Deref>::deref(&place) -> eq_block` terminator,
// we need to add all further statements to `eq_block`.
// Similarly, the normal test code should be generated for the `&str`, instead of the `String`.
block = eq_block;
place = ref_str;
ty = ref_str_ty;
}
let re_erased = tcx.lifetimes.re_erased;
let ref_str_ty = Ty::new_imm_ref(tcx, re_erased, tcx.types.str_);
let ref_str = self.temp(ref_str_ty, test.span);
let eq_block = self.cfg.start_new_block();
// `let ref_str: &str = <String as Deref>::deref(&place);`
self.call_deref(
block,
eq_block,
place,
Mutability::Not,
ty,
ref_str,
test.span,
);
self.non_scalar_compare(
eq_block,
success_block,
fail_block,
source_info,
value,
ref_str,
ref_str_ty,
);
} else if !ty.is_scalar() {
_ => {}
}

if !ty.is_scalar() {
// Use `PartialEq::eq` instead of `BinOp::Eq`
// (the binop can only handle primitives)
self.non_scalar_compare(
block,
success_block,
fail_block,
source_info,
value,
place,
expect,
expect_ty,
Operand::Copy(place),
ty,
);
} else {
assert_eq!(value.ty(), ty);
let expect = self.literal_operand(test.span, value);
let val = Operand::Copy(place);
assert_eq!(expect_ty, ty);
self.compare(
block,
success_block,
fail_block,
source_info,
BinOp::Eq,
expect,
val,
Operand::Copy(place),
);
}
}
Expand Down Expand Up @@ -371,12 +376,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
success_block: BasicBlock,
fail_block: BasicBlock,
source_info: SourceInfo,
value: Const<'tcx>,
mut val: Place<'tcx>,
mut expect: Operand<'tcx>,
expect_ty: Ty<'tcx>,
mut val: Operand<'tcx>,
mut ty: Ty<'tcx>,
) {
let mut expect = self.literal_operand(source_info.span, value);

// If we're using `b"..."` as a pattern, we need to insert an
// unsizing coercion, as the byte string has the type `&[u8; N]`.
//
Expand All @@ -391,7 +395,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
_ => None,
};
let opt_ref_ty = unsize(ty);
let opt_ref_test_ty = unsize(value.ty());
let opt_ref_test_ty = unsize(expect_ty);
match (opt_ref_ty, opt_ref_test_ty) {
// nothing to do, neither is an array
(None, None) => {}
Expand All @@ -410,11 +414,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
PointerCoercion::Unsize,
CoercionSource::Implicit,
),
Operand::Copy(val),
val,
ty,
),
);
val = temp;
val = Operand::Copy(temp);
}
if opt_ref_test_ty.is_some() {
let slice = self.temp(ty, source_info.span);
Expand Down Expand Up @@ -470,11 +474,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

const_: method,
})),
args: [Spanned { node: Operand::Copy(val), span: DUMMY_SP }, Spanned {
node: expect,
span: DUMMY_SP,
}]
.into(),
args: [Spanned { node: val, span: DUMMY_SP }, Spanned { node: expect, span: DUMMY_SP }]
.into(),
destination: eq_result,
target: Some(eq_block),
unwind: UnwindAction::Continue,
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,14 @@ impl<'v> RootCollector<'_, 'v> {
self.output.push(dummy_spanned(MonoItem::Static(def_id)));
}
DefKind::Const => {
// const items only generate mono items if they are
// actually used somewhere. Just declaring them is insufficient.
// Const items only generate mono items if they are actually used somewhere.
// Just declaring them is insufficient.

// but even just declaring them must collect the items they refer to
if let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id()) {
// But even just declaring them must collect the items they refer to
// unless their generics require monomorphization.
if !self.tcx.generics_of(id.owner_id).requires_monomorphization(self.tcx)
&& let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id())
{
collect_const_value(self.tcx, val, self.output);
}
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("aclass", Unstable(sym::arm_target_feature), &[]),
("aes", Unstable(sym::arm_target_feature), &["neon"]),
(
"atomics-32",
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
&[],
),
("crc", Unstable(sym::arm_target_feature), &[]),
("d32", Unstable(sym::arm_target_feature), &[]),
("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
Expand Down
7 changes: 3 additions & 4 deletions library/std/src/sys/pal/uefi/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ mod uefi_command_internal {
helpers::open_protocol(self.handle, loaded_image::PROTOCOL_GUID).unwrap();

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

unsafe {
Expand Down Expand Up @@ -706,9 +706,10 @@ mod uefi_command_internal {
res.push(QUOTE);
res.extend(prog.encode_wide());
res.push(QUOTE);
res.push(SPACE);

for arg in args {
res.push(SPACE);

// Wrap the argument in quotes to be treat as single arg
res.push(QUOTE);
for c in arg.encode_wide() {
Expand All @@ -719,8 +720,6 @@ mod uefi_command_internal {
res.push(c);
}
res.push(QUOTE);

res.push(SPACE);
}

res.into_boxed_slice()
Expand Down
5 changes: 3 additions & 2 deletions src/ci/docker/host-x86_64/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ENV PATH="/node/bin:${PATH}"

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

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down Expand Up @@ -68,4 +68,5 @@ ENV SCRIPT \
es-check es2019 ../src/librustdoc/html/static/js/*.js && \
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js && \
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js && \
tsc --project ../src/librustdoc/html/static/js/tsconfig.json
10 changes: 3 additions & 7 deletions src/librustdoc/html/static/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
These JavaScript files are incorporated into the rustdoc binary at build time,
and are minified and written to the filesystem as part of the doc build process.

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

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