Commit Graph

19780 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
ef4a7fb1b7 Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU
Mitigate `#[align]` name resolution ambiguity regression with a rename

Mitigates beta regression rust-lang/rust#143834 after a beta backport.

### Background on the beta regression

The name resolution regression arises due to rust-lang/rust#142507 adding a new feature-gated built-in attribute named `#[align]`. However, unfortunately even [introducing new feature-gated unstable built-in attributes can break user code](https://www.github.com/rust-lang/rust/issues/134963) such as

```rs
macro_rules! align {
    () => {
        /* .. */
    };
}

pub(crate) use align; // `use` here becomes ambiguous
```

### Mitigation approach

This PR renames `#[align]` to `#[rustc_align]` to mitigate the beta regression by:

1. Undoing the introduction of a new built-in attribute with a common name, i.e. `#[align]`.
2. Renaming `#[align]` to `#[rustc_align]`. The renamed attribute being `rustc_align` will not introduce new stable breakages, as attributes beginning with `rustc` are reserved and perma-unstable. This does mean existing nightly code using `fn_align` feature will additionally need to specify `#![feature(rustc_attrs)]`.

This PR is very much a short-term mitigation to alleviate time pressure from having to fully fix the current limitation of inevitable name resolution regressions that would arise from adding any built-in attributes. Long-term solutions are discussed in [#t-lang > namespacing macro attrs to reduce conflicts with new adds](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/namespacing.20macro.20attrs.20to.20reduce.20conflicts.20with.20new.20adds/with/529249622).

### Alternative mitigation options

[Various mitigation options were considered during the compiler triage meeting](https://github.com/rust-lang/rust/issues/143834#issuecomment-3084415277), and those consideration are partly reproduced here:

- Reverting the PR doesn't seem very minimal/trivial, and carries risks of its own.
- Rename to a less-common but aim-to-stabilization name is itself not safe nor convenient, because (1) that risks introducing new regressions (i.e. ambiguity against the new name), and (2) lang would have to FCP the new name hastily for the mitigation to land timely and have a chance to be backported. This also makes the path towards stabilization annoying.
- Rename the attribute to a rustc attribute, which will be perma-unstable and does not cause new ambiguities in stable code.
    - This alleviates the time pressure to address *this* regression, or for lang to have to rush an FCP for some new name that can still break user code.
    - This avoids backing out a whole implementation.

### Review advice

This PR is best reviewed commit-by-commit.

- Commit 1 adds a test `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` which demonstrates the current name resolution regression re. `align`. This test fails against current master.
- Commit 2 carries out the renames and test reblesses. Notably, commit 2 will cause `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` to change from fail (nameres regression) to pass.

This PR, if the approach still seems acceptable, will need a beta-backport to address the beta regression.
2025-07-22 00:54:28 +08:00
许杰友 Jieyou Xu (Joe)
2e0748b185 Rollup merge of #143985 - makai410:rp-rename, r=oli-obk
rustc_public: de-StableMIR-ize

This PR updates relevant docs about StableMIR, basically just rewording StableMIR/SMIR to rustc_public/rustc_public's IR.

The README.md in the `rustc_public` crate is out-dated. I plan to rewrite it after we fork rustc_public into its own repository.

This PR doesn't change the fact that we still use `-Z unpretty=stable-mir` as a rustc parameter for printing the IR, since I feel it's a bit verbose and weird if we use `-Z unpretty=rustc-public-ir`. I was wondering if we can have a short and easy alias for rustc_public's IR.
2025-07-22 00:54:27 +08:00
许杰友 Jieyou Xu (Joe)
1f8b531b54 Rollup merge of #143768 - Randl:const-try, r=oli-obk
Constify Try, From, TryFrom and relevant traits
2025-07-22 00:54:26 +08:00
许杰友 Jieyou Xu (Joe)
a99f3af990 Rollup merge of #143430 - cjgillot:extra-lifetime-swap, r=oli-obk
Lower extra lifetimes before normal generic params.

Fixes https://github.com/rust-lang/rust/issues/143413
2025-07-22 00:54:25 +08:00
许杰友 Jieyou Xu (Joe)
5e3eb25125 Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk
gpu offload host code generation

r? ghost

This will generate most of the host side code to use llvm's offload feature.
The first PR will only handle automatic mem-transfers to and from the device.
So if a user calls a kernel, we will copy inputs back and forth, but we won't do the actual kernel launch.
Before merging, we will use LLVM's Info infrastructure to verify that the memcopies match what openmp offloa generates in C++. `LIBOMPTARGET_INFO=-1 ./my_rust_binary` should print that a memcpy to and later from the device is happening.

A follow-up PR will generate the actual device-side kernel which will then do computations on the GPU.
A third PR will implement manual host2device and device2host functionality, but the goal is to minimize cases where a user has to overwrite our default handling due to performance issues.

I'm trying to get a full MVP out first, so this just recognizes GPU functions based on magic names. The final frontend will obviously move this over to use proper macros, like I'm already doing it for the autodiff work.
This work will also be compatible with std::autodiff, so one can differentiate GPU kernels.

Tracking:
- https://github.com/rust-lang/rust/issues/131513
2025-07-22 00:54:24 +08:00
Esteban Küber
8df93e6966 Tweak spans when encountering multiline initializer in move error
```
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
   |
LL |     let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
   |         ----- captured outer variable
...
LL |     f(Box::new(|a| {
   |                --- captured by this `FnMut` closure
LL |
LL |         foo(f);
   |             ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait
```

instead of

```
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
   |
LL |       let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
   |  _________-----___-
   | |         |
   | |         captured outer variable
LL | |         let _ = s.len();
LL | |     };
   | |_____- move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait
LL |       f(Box::new(|a| {
   |                  --- captured by this `FnMut` closure
LL |
LL |           foo(f);
   |               ^ `f` is moved here
```
2025-07-21 16:21:23 +00:00
Esteban Küber
5082e6a300 Generalize logic pointing at binding moved into closure
Account not only for `fn` parameters when moving non-`Copy` values into closure, but also for let bindings.

```
error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-move-by-capture.rs:9:29
   |
LL |     let bar: Box<_> = Box::new(3);
   |         ---  ------ move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     let _g = to_fn_mut(|| {
   |                        -- captured by this `FnMut` closure
LL |         let _h = to_fn_once(move || -> isize { *bar });
   |                             ^^^^^^^^^^^^^^^^   ---- variable moved due to use in closure
   |                             |
   |                             `bar` is moved here
   |
help: consider cloning the value before moving it into the closure
   |
LL ~         let value = bar.clone();
LL ~         let _h = to_fn_once(move || -> isize { value });
   |
```

```
error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure
  --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:12:9
   |
LL |     let y = vec![format!("World")];
   |         -   ---------------------- move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     call(|| {
   |          -- captured by this `Fn` closure
LL |         y.into_iter();
   |         ^ ----------- `y` moved due to this method call
   |         |
   |         `y` is moved here
   |
note: `into_iter` takes ownership of the receiver `self`, which moves `y`
  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |         <Vec<String> as Clone>::clone(&y).into_iter();
   |         +++++++++++++++++++++++++++++++ +
help: consider cloning the value if the performance cost is acceptable
   |
LL |         y.clone().into_iter();
   |          ++++++++
```
2025-07-21 16:21:23 +00:00
Esteban Küber
690ae523e5 Tweak borrowck label pointing at !Copy value moved into closure
When encountering a non-`Copy` value that is moved into a closure which is coming directly from a fn parameter, point at the parameter's type when mentioning it is not `Copy`.

Before:

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             --- captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            ---
   |            |
   |            variable moved due to use in coroutine
   |            move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```

After:

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
```
2025-07-21 16:21:23 +00:00
Michael Goulet
b5d36e5294 Dont ICE on copy error being suppressed due to overflow 2025-07-21 16:07:29 +00:00
Oli Scherer
b2f8b40633 Don't ICE on non-TypeId metadata within TypeId 2025-07-21 14:23:20 +00:00
Evgenii Zheltonozhskii
3c76e3d002 Constify Try, From, TryFrom 2025-07-21 12:49:45 +03:00
Jieyou Xu
74ba9cbae4 Don't use another main test file as auxiliary
In this case, the exact extern crate isn't very important.

This is part of the changes needed to address the spurious failures from
a main test `../removing-extern-crate.rs` being both an auxiliary and a
main test file, causing fs races due to multiple `rustc` processes in
multiple test threads trying to build the main test file both as a main
test and also as an auxiliary at around the same time.
2025-07-21 16:58:54 +08:00
bors
67819923ac Auto merge of #144238 - jhpratt:rollup-xb8aida, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#144144 (tests: Skip supported-crate-types test on musl hosts)
 - rust-lang/rust#144159 (opt-dist: change build_dir field to be an actual build dir)
 - rust-lang/rust#144162 (Debug impls for DropElaborators)
 - rust-lang/rust#144189 (Add non-regression test for rust-lang/rust#144168)
 - rust-lang/rust#144216 (Don't consider unstable fields always-inhabited)
 - rust-lang/rust#144229 (Miri subtree update)
 - rust-lang/rust#144230 (Option::as_slice: fix comment)
 - rust-lang/rust#144235 (Fix run-make tests on musl hosts)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-21 08:42:52 +00:00
Jacob Pratt
830b8237de Rollup merge of #144216 - Nadrieril:revert-pin-hack, r=compiler-errors
Don't consider unstable fields always-inhabited

This reverts the hack in https://github.com/rust-lang/rust/pull/133889 now that `Pin`'s field is no longer public.

Fixes https://github.com/rust-lang/rust/issues/143468.

r? ```@compiler-errors```
2025-07-20 23:11:22 -04:00
Jacob Pratt
b81b2a7ecf Rollup merge of #144189 - lqd:test-144168, r=petrochenkov
Add non-regression test for #144168

This is a non-regression test for issue rust-lang/rust#144168, reduced from `zerocopy`, to go with https://github.com/rust-lang/rust/pull/144172 since it had no test yet, and we didn't want to delay it from landing.

Closes rust-lang/rust#144168

I've checked that the test does fail without rust-lang/rust#144172.
2025-07-20 23:11:21 -04:00
Jacob Pratt
9fdfaef403 Rollup merge of #144144 - Gelbpunkt:musl-crate-types-test, r=compiler-errors
tests: Skip supported-crate-types test on musl hosts

This test depends on the target-specific default of crt-static for musl targets. However, running the testsuite on a musl host requires setting `crt-static` to `false`, as it wouldn't otherwise be possible to build rustc. This in turn will enable `-Ctarget-feature=-crt-static` for all tests, mismatching the expected `+crt-static` for the musl target tested in this testcase.

Since this test specifically tests the default value of `crt-static` for the musl target, ignoring it entirely makes more sense than manually setting `-Ctarget-feature=+crt-static` here, but both would be valid approaches.
2025-07-20 23:11:20 -04:00
bors
e05ab47e6c Auto merge of #143833 - scottmcm:final-mcp-838, r=compiler-errors
Ban projecting into SIMD types [MCP838]

Closes https://github.com/rust-lang/compiler-team/issues/838

The actual compiler change here is tiny; there's just a bazillion tests to update.

~~Since I'm sure I've missed some, for now~~
~~r ghost~~

try-job: test-various
try-job: x86_64-gnu-nopt
2025-07-21 02:31:56 +00:00
Camille GILLOT
538b0004bc Also bail out if predicates contain errors. 2025-07-20 23:15:24 +00:00
Camille GILLOT
1987471d05 Consider parent predicates in ImpossiblePredicates pass. 2025-07-20 22:45:07 +00:00
David Mládek
725523e9b0 tests: cover more exported_private_dependencies cases 2025-07-20 21:11:39 +02:00
Michael Goulet
1e96d7a553 Consider param-env for fast path 2025-07-20 17:45:01 +00:00
Scott McMurray
41ce1ed252 Ban projecting into SIMD types [MCP838] 2025-07-20 10:22:09 -07:00
Scott McMurray
25a804ab06 ...and wasm tests too 2025-07-20 10:15:14 -07:00
Scott McMurray
08b816ff18 So many test updates x_x 2025-07-20 10:15:14 -07:00
Nadrieril
3567ab19a0 Don't consider unstable fields always-inhabited
This reverts the hack in https://github.com/rust-lang/rust/pull/133889
now that `Pin`'s field is no longer public.
2025-07-20 18:23:18 +02:00
Guillaume Gomez
ae3708e4b2 Rollup merge of #144190 - scottmcm:spanned-errors-in-mir-validation, r=RalfJung
Give a message with a span on MIR validation error

It was handy to get a source+line link for rust-lang/rust#143833, even if it's just to the function and not necessarily to the statement.

r? mir
2025-07-20 15:34:08 +02:00
Guillaume Gomez
8e7601e10e Rollup merge of #144150 - Gelbpunkt:globalmerge, r=Mark-Simulacrum
tests: assembly: cstring-merging: Disable GlobalMerge pass

The test relies on LLVM not merging all the globals into one and would currently otherwise fail on powerpc64le.

See https://github.com/llvm/llvm-project/blob/release/20.x/llvm/lib/CodeGen/GlobalMerge.cpp and here's the assembly generated prior to disabling the pass:

<details>

<summary>Expand me</summary>

```asm
	.abiversion 2
	.file	"cstring_merging.5aa81ea7b99b31fe-cgu.0"
	.section	.text.cstr,"ax",``@progbits``
	.globl	cstr
	.p2align	4
	.type	cstr,``@function``
cstr:
.Lfunc_begin0:
	.cfi_startproc
.Lfunc_gep0:
	addis 2, 12, .TOC.-.Lfunc_gep0@ha
	addi 2, 2, .TOC.-.Lfunc_gep0@l
.Lfunc_lep0:
	.localentry	cstr, .Lfunc_lep0-.Lfunc_gep0
	addis 3, 2, .L_MergedGlobals@toc@ha
	li 4, 4
	addi 3, 3, .L_MergedGlobals@toc@l
	addi 3, 3, 4
	blr
	.long	0
	.quad	0
.Lfunc_end0:
	.size	cstr, .Lfunc_end0-.Lfunc_begin0
	.cfi_endproc

	.section	.text.manual_cstr,"ax",``@progbits``
	.globl	manual_cstr
	.p2align	4
	.type	manual_cstr,``@function``
manual_cstr:
.Lfunc_begin1:
	.cfi_startproc
.Lfunc_gep1:
	addis 2, 12, .TOC.-.Lfunc_gep1@ha
	addi 2, 2, .TOC.-.Lfunc_gep1@l
.Lfunc_lep1:
	.localentry	manual_cstr, .Lfunc_lep1-.Lfunc_gep1
	addis 3, 2, .L_MergedGlobals@toc@ha
	li 4, 4
	addi 3, 3, .L_MergedGlobals@toc@l
	addi 3, 3, 8
	blr
	.long	0
	.quad	0
.Lfunc_end1:
	.size	manual_cstr, .Lfunc_end1-.Lfunc_begin1
	.cfi_endproc

	.type	CSTR,``@object``
	.section	.data.rel.ro.CSTR,"aw",``@progbits``
	.globl	CSTR
	.p2align	3, 0x0
CSTR:
	.quad	.L_MergedGlobals
	.size	CSTR, 8

	.type	.L_MergedGlobals,``@object``
	.section	.rodata..L_MergedGlobals,"a",``@progbits``
.L_MergedGlobals:
	.asciz	"foo"
	.asciz	"bar"
	.asciz	"baz"
	.size	.L_MergedGlobals, 12

.set .Lanon.a643e9a6bba67b7953be2b5f96e0e802.0, .L_MergedGlobals
	.size	.Lanon.a643e9a6bba67b7953be2b5f96e0e802.0, 4
.set .Lanon.a643e9a6bba67b7953be2b5f96e0e802.1, .L_MergedGlobals+4
	.size	.Lanon.a643e9a6bba67b7953be2b5f96e0e802.1, 4
.set .Lanon.a643e9a6bba67b7953be2b5f96e0e802.2, .L_MergedGlobals+8
	.size	.Lanon.a643e9a6bba67b7953be2b5f96e0e802.2, 4
	.ident	"rustc version 1.90.0-dev"
	.section	".note.GNU-stack","",``@progbits``
```

</details>
2025-07-20 15:34:08 +02:00
Guillaume Gomez
1e6ef245cd Rollup merge of #144143 - Gelbpunkt:target-features-crt-static, r=RalfJung
Fix `-Ctarget-feature`s getting ignored after `crt-static`

The current behaviour introduced by commit a50a3b8e31 would discard any target features specified after `crt-static` (the only member of `RUSTC_SPECIFIC_FEATURES`). This is because it returned instead of continuing processing the next feature.

I wasn't entirely sure how the regression test should look like, but this one should do. If anyone has some suggestions, I'm happy to learn, it's my first test :)

I've confirmed that the test fails without the fix on `powerpc64le-unknown-linux-musl` and `x86_64-unknown-linux-gnu`.

cc ``@RalfJung``
2025-07-20 15:34:07 +02:00
Guillaume Gomez
2461d6ccb8 Rollup merge of #143720 - scottmcm:rvalue-always-operand, r=lcnr
Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too

The conversation in https://github.com/rust-lang/rust/pull/143502#discussion_r2189410911 made be realize how easy this is to handle, since the only possibilty is ZSTs -- everything else ends up with the destination being `LocalKind::Memory` and thus doesn't call `codegen_rvalue_operand` at all.

This gets us perilously close to a world where `rvalue_creates_operand` only ever returns true.  (See rust-lang/rust#143860 for more.)
2025-07-20 15:34:05 +02:00
Camille GILLOT
7da6fd1221 Lower extra lifetimes before normal generic params. 2025-07-20 13:21:22 +00:00
Camille GILLOT
313dff14b9 Add test. 2025-07-20 13:21:22 +00:00
Nadrieril
e9fb744207 Add test 2025-07-20 14:49:43 +02:00
Matthias Krüger
23c81a75e1 Rollup merge of #144142 - compiler-errors:itib, r=fmease
Add implicit sized bound to trait ascription types

r? ```@fmease``` or reassign

Thanks for catching this :)

Fixes rust-lang/rust#144135
2025-07-20 08:56:09 +02:00
Matthias Krüger
d24684ef4f Rollup merge of #144116 - nikic:llvm-21-fixes, r=dianqk
Fixes for LLVM 21

This fixes compatibility issues with LLVM 21 without performing the actual upgrade. Split out from https://github.com/rust-lang/rust/pull/143684.

This fixes three issues:
 * Updates the AMDGPU data layout for address space 8.
 * Makes emit-arity-indicator.rs a no_core test, so it doesn't fail on non-x86 hosts.
 * Explicitly sets the exception model for wasm, as this is no longer implied by `-wasm-enable-eh`.
2025-07-20 08:56:08 +02:00
Matthias Krüger
bfcfde97c2 Rollup merge of #144078 - bjorn3:fix_test, r=compiler-errors
Fix debuginfo-lto-alloc.rs test

This should have used build-pass rather than check-pass.
2025-07-20 08:56:07 +02:00
Matthias Krüger
dda505850a Rollup merge of #143988 - GuillaumeGomez:alias-inexact, r=lolbinarycat
[rustdoc] Make aliases search support partial matching

Fixes rust-lang/rust#140782.

To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok.

This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. 😉

cc ```@lolbinarycat```
2025-07-20 08:56:06 +02:00
Matthias Krüger
6d7d366fd3 Rollup merge of #141260 - LuigiPiucco:volatile-null, r=RalfJung
Allow volatile access to non-Rust memory, including address 0

This PR relaxes the `ub_check` in the `read_volatile`/`write_volatile` pointer operations to allow passing null. This is needed to support processors which hard-code peripheral registers on address 0, like the AVR chip ATtiny1626. LLVM understands this as valid and handles it correctly, as tested in my [PR to add a note about it](6387c82255 (diff-81bbb96298c32fa901beb82ab3b97add27a410c01d577c1f8c01000ed2055826)) (rustc generates the same LLVM IR as expected there when this PR is applied, and consequently the same AVR assembly).

Follow-up and implementation of the discussions in:
- https://internals.rust-lang.org/t/pre-rfc-conditionally-supported-volatile-access-to-address-0/12881/7
- https://github.com/Rahix/avr-device/pull/185;
- [#t-lang > Adding the possibility of volatile access to address 0](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Adding.20the.20possibility.20of.20volatile.20access.20to.20address.200/with/513303502)
- https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303

r? ````@RalfJung````

Also fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/29 (about as good as it'll get, null will likely never be a "normal" address in Rust)
2025-07-20 08:56:05 +02:00
Scott McMurray
4b8f869c63 Split repeat-operand codegen test
Looks like the output it's looking for can be in different orders, so separate tests will fix that.
2025-07-19 20:50:02 -07:00
Scott McMurray
0586c63e07 Allow Rvalue::Repeat to return true in rvalue_creates_operand too
The conversation in 143502 made be realize how easy this is to handle, since the only possibilty is ZSTs -- everything else ends up with the destination being `LocalKind::Memory` and thus doesn't call `codegen_rvalue_operand` at all.

This gets us perilously close to a world where `rvalue_creates_operand` only ever returns true.  I'll try out such a world next :)
2025-07-19 20:50:02 -07:00
Rémy Rakic
8f77d5463a add non-regression test for issue 144168 2025-07-19 21:43:50 +00:00
Scott McMurray
14d097f641 Give a message with a span on validation error 2025-07-19 14:14:12 -07:00
Martin Nordholts
e1d4f2a0c2 tests: Require run-fail ui tests to have an exit code (SIGABRT not ok)
And introduce two new directives for ui tests:
* `run-crash`
* `run-fail-or-crash`

Normally a `run-fail` ui test like tests that panic shall not be
terminated by a signal like `SIGABRT`. So begin having that as a hard
requirement.

Some of our current tests do terminate by a signal/crash however.
Introduce and use `run-crash` for those tests. Note that Windows crashes
are not handled by signals but by certain high bits set on the process
exit code. Example exit code for crash on Windows: `0xc000001d`.
Because of this, we define "crash" on all platforms as "not exit with
success and not exit with a regular failure code in the range 1..=127".

Some tests behave differently on different targets:
* Targets without unwind support will abort (crash) instead of exit with
  failure code 101 after panicking. As a special case, allow crashes for
  `run-fail` tests for such targets.
* Different sanitizer implementations handle detected memory problems
  differently. Some abort (crash) the process while others exit with
  failure code 1. Introduce and use `run-fail-or-crash` for such tests.
2025-07-19 18:44:07 +02:00
bors
12865ffd0d Auto merge of #144166 - matthiaskrgr:rollup-wccepuo, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#141076 (fix Zip unsoundness (again))
 - rust-lang/rust#142444 (adding run-make test to autodiff)
 - rust-lang/rust#143704 (Be a bit more careful around exotic cycles in in the inliner)
 - rust-lang/rust#144073 (Don't test panic=unwind in panic_main.rs on Fuchsia)
 - rust-lang/rust#144083 (miri sleep tests: increase slack)
 - rust-lang/rust#144092 (bootstrap: Detect musl hosts)
 - rust-lang/rust#144098 (Do not lint private-in-public for RPITIT)
 - rust-lang/rust#144103 (Rename `emit_unless` to `emit_unless_delay`)
 - rust-lang/rust#144108 (Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling)
 - rust-lang/rust#144115 (fix outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-19 11:10:04 +00:00
bors
83825dd277 Auto merge of #143784 - scottmcm:enums-again-new-ex2, r=dianqk
Simplify discriminant codegen for niche-encoded variants which don't wrap across an integer boundary

Inspired by rust-lang/rust#139729, this attempts to be a much-simpler and more-localized change while still making a difference.  (Specifically, this does not try to solve the problem with select-sinking, leaving that to be fixed by https://github.com/llvm/llvm-project/issues/134024 -- once it gets released -- instead of in rustc's codegen.)

What this *does* improve is checking for the variant in a 3+ variant enum when that variant is the type providing the niche.  Something like `if let Foo::WithBool(_) = ...` previously compiled to `ugt(add(x, -2), 2)`, which is non-trivial to think about because it's depending on the unsigned wrapping to shift the 0/1 up above 2.  With this PR it compiles to just `ult(x, 2)`, which is probably what you'd have written yourself if you were doing it by hand to look for "is this byte a bool?".

That's done by leaving most of the codegen alone, but adding a couple new special cases to the `is_niche` check.  The default looks at the relative discriminant, but in the common cases where there's no wraparound involved, we can just check the original value, rather than the offsetted one.

The first commit just adds some tests, so the best way to see the effect of this change is to look at the second commit and how it updates the test expectations.
2025-07-19 08:03:40 +00:00
Matthias Krüger
ae77628a53 Rollup merge of #144108 - CaiWeiran:run-make_test, r=jieyouxu
Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling

The test tests/run-make/link-eh-frame-terminator/rmake.rs fails to link when cross-compiling. Therefore, it should be ignored in cross-compilation environments.
See [commit a27bdea](a27bdea4b7) and [commit 2beccc4](2beccc4d8e) for reference.
2025-07-19 08:55:37 +02:00
Matthias Krüger
4b9471771b Rollup merge of #144098 - cjgillot:lint-rpitit, r=compiler-errors
Do not lint private-in-public for RPITIT

Fixes the hard error introduced by https://github.com/rust-lang/rust/pull/143357

Instead of trying to accept this hard error directly, this PR copies tests from https://github.com/rust-lang/rust/pull/144020 and removes the error.

If the behaviour is actually desirable, the second commit can be reverted with a proper crater run.

cc https://github.com/rust-lang/rust/issues/143531 for bookkeeping

r? `@compiler-errors`
2025-07-19 08:55:36 +02:00
Matthias Krüger
5e2416fd76 Rollup merge of #144073 - erickt:ignore-test-on-fuchsia, r=lqd
Don't test panic=unwind in panic_main.rs on Fuchsia

````@Enselic```` added a few new test conditions to tests/ui/panics/panic-main.rs in rust-lang/rust#142304, but it is unfortunately causing the test to fail for Fuchsia with the `panic=unwind` modes since we compile Rust for Fuchsia with `panic=abort`. This patch just ignores the test for Fuchsia.

Note that this test might also need to filter out a few other platforms, since another panicking test we exclude from Fuchsia https://github.com/rust-lang/rust/blob/master/tests/ui/panics/runtime-switch.rs also excludes running on msvc, android, openbsd, and wasm, but I'm not familiar with those platforms so I didn't want to add them here.

cc ````@compile-errors,```` who reviewed the initial PR
2025-07-19 08:55:35 +02:00
Matthias Krüger
3b4d79c949 Rollup merge of #143704 - compiler-errors:cycle-exotic, r=cjgillot
Be a bit more careful around exotic cycles in in the inliner

Copied from the comment here: https://github.com/rust-lang/rust/issues/143700#issuecomment-3053810353

---

```rust
#![feature(fn_traits)]

#[inline]
pub fn a() {
    FnOnce::call_once(a, ());
    FnOnce::call_once(b, ());
}

#[inline]
pub fn b() {
    FnOnce::call_once(b, ());
    FnOnce::call_once(a, ());
}
```

This should demonstrate the issue. For ease of discussion, I'm gonna call the two fn-def types `{a}` and `{b}`.

When collecting the cyclic local callees in `mir_callgraph_cyclic` for `a`, we first check the first call terminator in `a`. We end up calling process on `<{a} as FnOnce>::call_once`, which ends up visiting `a`'s instance again. This is cyclical. However, we don't end up marking `FnOnce::call_once` as a cyclical def id because it's a foreign item. That's fine.

When visiting the second call terminator in `a`, which is `<{b} as FnOnce>::call_once`, we end up recursing into `b`. We check the first terminator, which is `<{b} as FnOnce>::call_once`, but although that is its own mini cycle, it doesn't consider itself a cycle for the purpose of this query because it doesn't involve the *root*. However, when we visit the *second* terminator in `b`, which is `<{a} as FnOnce>::call_once`, we end up **erroneously** *not* considering that call to be cyclical since we've already inserted it into our set of seen instances, and as a consequence we don't recurse into it. This means that we never collect `b` as recursive.

Do this in the flipped case too, and we end up having two functions which mututally do not consider each other to be recursive participants. This leads to a query cycle.

---

I ended up also renaming some variables so I could more clearly understand their responsibilities in this code. Let me know if the renames are not welcome.

Fixes https://github.com/rust-lang/rust/issues/143700
r? `@cjgillot`
2025-07-19 08:55:34 +02:00
Matthias Krüger
44ee51de0b Rollup merge of #142444 - KMJ-007:autodiff-codegen-test, r=ZuseZ4
adding run-make test to autodiff

r? `@ZuseZ4`
2025-07-19 08:55:34 +02:00
bors
1079c5edb2 Auto merge of #144145 - matthiaskrgr:rollup-swc74s4, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#138554 (Distinguish delim kind to decide whether to emit unexpected closing delimiter)
 - rust-lang/rust#142673 (Show the offset, length and memory of uninit read errors)
 - rust-lang/rust#142693 (More robustly deal with relaxed bounds and improve their diagnostics)
 - rust-lang/rust#143382 (stabilize `const_slice_reverse`)
 - rust-lang/rust#143928 (opt-dist: make llvm builds optional)
 - rust-lang/rust#143961 (Correct which exploit mitigations are enabled by default)
 - rust-lang/rust#144050 (Fix encoding of link_section and no_mangle cross crate)
 - rust-lang/rust#144059 (Refactor `CrateLoader` into the `CStore`)
 - rust-lang/rust#144123 (Generalize `unsize` and `unsize_into` destinations)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-19 05:02:40 +00:00