Commit Graph

21219 Commits

Author SHA1 Message Date
bors
eed187cfce Auto merge of #144528 - matthiaskrgr:rollup-felcjc1, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#144226 (Do not assert layout in KnownPanicsLint.)
 - rust-lang/rust#144385 (Optimize performance by inline in macro hygiene system)
 - rust-lang/rust#144454 (move uefi test to run-make)
 - rust-lang/rust#144455 (Unify LLVM ctlz/cttz intrinsic generation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-27 09:38:27 +00:00
Matthias Krüger
9b3d4cbb06 Rollup merge of #144454 - folkertdev:uefi-tests, r=jieyouxu
move uefi test to run-make

Turn the `uefi` test into a more standard `run-make` test, and execute it using the `test-various` CI job like before.

This is just a straightforward translation of the python code, but using `run-make` to supply the target (hence the 3 separate calls in the docker file).

r? ```@jieyouxu```
cc ```@nicholasbishop```

try-job: test-various
2025-07-27 10:19:02 +02:00
Matthias Krüger
58f10376f4 Rollup merge of #144226 - cjgillot:known-panics-panics, r=oli-obk
Do not assert layout in KnownPanicsLint.

Fixes rust-lang/rust#121176
Fixes rust-lang/rust#129109
Fixes rust-lang/rust#130970
Fixes rust-lang/rust#131347
Fixes rust-lang/rust#139872
Fixes rust-lang/rust#140332
2025-07-27 10:19:00 +02:00
bors
86ef320294 Auto merge of #144347 - scottmcm:ssa-enums-v0, r=WaffleLapkin
No longer need `alloca`s for consuming `Result<!, i32>` and similar

In optimized builds GVN gets rid of these already, but in `opt-level=0` we actually make `alloca`s for this, which particularly impacts `?`-style things that use actually-only-one-variant types like this.

While doing so, rewrite `LocalAnalyzer::process_place` to be non-recursive, solving a 6+ year old FIXME.

r? codegen
2025-07-27 06:37:55 +00:00
Miguel Ojeda
558796b460 rustdoc: save target modifiers
`rustdoc` was filling a `target_modifiers` variable, but it was not
using the result.

In turn, that means that trying to use a dependency that set a target
modifier fails.

For instance, running:

```sh
RUSTC_BOOTSTRAP=1 rustc --edition=2024 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null --emit=metadata -Zfixed-x18 --crate-type rlib --crate-name core $(rustc --print sysroot)/lib/rustlib/src/rust/library/core/src/lib.rs

echo '#![allow(internal_features)]
' | RUSTC_BOOTSTRAP=1 rustdoc --edition=2021 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null -Zfixed-x18 --extern core=libcore.rmeta -
```

will fail with:

```text
error: mixing `-Zfixed-x18` will cause an ABI mismatch in crate `rust_out`
  |
  = help: the `-Zfixed-x18` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
  = note: unset `-Zfixed-x18` in this crate is incompatible with `-Zfixed-x18=` in dependency `core`
  = help: set `-Zfixed-x18=` in this crate or unset `-Zfixed-x18` in `core`
  = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=fixed-x18` to silence this error
```

Thus save the targets modifiers in `Options` to then pass it to the
session options, so that eventually the diff can be performed as expected
in `report_incompatible_target_modifiers()`.

Fixes: https://github.com/rust-lang/rust/issues/144521
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-07-27 05:21:47 +02:00
Jacob Pratt
8aa3d41b85 Rollup merge of #144480 - Zalathar:revert-empty-span, r=Zalathar
Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen"

Surprisingly, rust-lang/rust#144298 alone (extracted from rust-lang/rust#140847) was enough to re-trigger the failures observed in https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286.

---

This reverts commit f877aa7d14.

---

r? ghost
2025-07-26 22:42:39 -04:00
Jacob Pratt
e04daf98f1 Rollup merge of #144453 - WaffleLapkin:canonical-build-root, r=jieyouxu
canonicalize build root in `tests/run-make/linker-warning`

r? jieyouxu

This is similar to rust-lang/rust#139823 -- the test fails for me because my build dir is a symlink.
2025-07-26 22:42:38 -04:00
Jacob Pratt
ba4a69134e Rollup merge of #144430 - Gelbpunkt:aarch64-outline-atomics-target, r=Noratrieb
tests: aarch64-outline-atomics: Remove hardcoded target

Since this test is limited to aarch64 and linux hosts, the `--target` flag is entirely unnecessary and only breaks this on musl hosts. Let the compiler use the default target instead.
2025-07-26 22:42:37 -04:00
Jacob Pratt
c92d61d121 Rollup merge of #144409 - GuillaumeGomez:macro-expansion-early-abort, r=oli-obk
Stop compilation early if macro expansion failed

Fixes rust-lang/rust#116180.

So there isn't really a type that is central for macro expansion and some errors are actually emitted (because the resolution happens after the expansion I suppose) after the expansion pass (like "not found macro"). Sometimes, errors are only emitted on the second "try" (to improve error output). So I couldn't reach a similar solution than what was done in https://github.com/rust-lang/rust/pull/133937 and suggested by ````@estebank```` in https://github.com/rust-lang/rust/issues/116180#issuecomment-3109468922. But maybe I missed something?

So in the end, I realized that there is method called every time (except one, described below) a macro error is actually emitted: `ExtCtxt::trace_macros_diag`. Considering I updated what it did, I renamed it into `macro_error_and_trace_macros_diag` to better reflect it.

There is only one call of `trace_macros_diag` which isn't reporting an error but just used for `macro_trace` feature, so I kept it as is.

r? ````@oli-obk````
2025-07-26 22:42:35 -04:00
Jacob Pratt
c96c80250e Rollup merge of #144379 - folkertdev:c-variadic-same-program-multiple-abis, r=RalfJung
test using multiple c-variadic ABIs in the same program

tracking issue: https://github.com/rust-lang/rust/issues/100189

Check that multiple c-variadic calling conventions can be used in the same program.

Clang and gcc reject defining functions with a non-default calling convention and a variable
argument list, so C programs that use multiple c-variadic calling conventions are unlikely
to come up. Here we validate that our codegen backends do in fact generate correct code.

(CI will not run this test because it runs on aarch64, I would like to at least test that this runs on windows)

try-job: `x86_64-gnu`
try-job: `x86_64-msvc-*`
try-job: `x86_64-apple-2`
2025-07-26 22:42:34 -04:00
Jacob Pratt
e2c2d1a493 Rollup merge of #144359 - RalfJung:vararg-codegen, r=compiler-errors
add codegen test for variadics

This is a part of https://github.com/rust-lang/rust/pull/144066 that can land without FCP.
2025-07-26 22:42:33 -04:00
bors
283a0746a2 Auto merge of #143860 - scottmcm:transmute-always-rvalue, r=WaffleLapkin
Let `codegen_transmute_operand` just handle everything

When combined with rust-lang/rust#143720, this means `rvalue_creates_operand` can just return `true` for *every* `Rvalue`.  (A future PR could consider removing it, though just letting it optimize out is fine for now.)

It's nicer anyway, IMHO, because it avoids needing the layout checks to be consistent in the two places, and thus is an overall reduction in code.  Plus it's a more helpful building block when used in other places this way.

(TBH, it probably would have been better to have it this way the whole time, but I clearly didn't understand `rvalue_creates_operand` when I originally wrote rust-lang/rust#109843.)
2025-07-26 22:45:18 +00:00
Camille GILLOT
8817572b45 Do not check Sync during type_of. 2025-07-26 21:53:13 +00:00
Camille GILLOT
a1f5a6d781 Perform check_private_in_public by module. 2025-07-26 21:21:04 +00:00
Jonathan Brouwer
fea7809edb Update test results
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-26 20:26:15 +02:00
Matthias Krüger
576af9b779 Rollup merge of #144462 - Kobzol:pretty-print-self-profile-args, r=RalfJung
Allow pretty printing paths with `-Zself-profile-events=args`

`-Zself-profile-events=args` is pretty heavy and can pretty print a lot of stuff. Rather than hunting down specific cases where this happens, I'd just allow calling `trimmed_def_paths` in this mode.

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

r? `@RalfJung`
2025-07-26 15:28:03 +02:00
Matthias Krüger
43096cc932 Rollup merge of #144376 - estebank:issue-143795, r=lcnr
Suggest unwrapping when private method name is available in inner type

Given

```rust
fn main() {
    let maybe_vec = Some(vec![1,2,3]);
    assert_eq!(maybe_vec.len(), 3);
}
```

suggest unwraping `maybe_vec` to call `.len()` on the `Vec<_>`.

```
error[E0624]: method `len` is private
  --> $DIR/enum-method-probe.rs:61:9
   |
LL |     res.len();
   |         ^^^ private method
  --> $SRC_DIR/core/src/option.rs:LL:COL
   |
   = note: private method defined here
   |
note: the method `len` exists on the type `Vec<{integer}>`
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`
   |
LL |     res.expect("REASON").len();
   |        +++++++++++++++++
```

When a method isn't available, we emit E0599, but when it is private we emit E0624. We now just invoke the same suggestion logic from the later that we already did in the former.

Fix rust-lang/rust#143795.
2025-07-26 15:27:59 +02:00
Matthias Krüger
c9541a2bf8 Rollup merge of #144331 - jplatte:matches-allow-non_exhaustive_omitted_patterns, r=Nadrieril
Disable non_exhaustive_omitted_patterns within matches! macro

Closes rust-lang/rust#117304.

I believe I can skip all of the bootstrap stuff mentioned in https://github.com/rust-lang/rust/issues/117304#issuecomment-1784414453 due to https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/, right?

cc `@Jules-Bertholet`
2025-07-26 15:27:58 +02:00
Martin Nordholts
534b1355ef tests: Add test for basic line-by-line stepping in a debugger
Let's wait with lldb testing until the test works properly with gdb.
2025-07-26 13:06:21 +02:00
Folkert de Vries
69ebf7049f test using multiple c-variadic ABIs in the same program 2025-07-26 12:26:05 +02:00
Folkert de Vries
bd7b023a6b move uefi test to run-make 2025-07-26 12:19:02 +02:00
bors
8708f3cd1f Auto merge of #144490 - tgross35:rollup-ps0utme, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#140871 (Don't lint against named labels in `naked_asm!`)
 - rust-lang/rust#141663 (rustdoc: add ways of collapsing all impl blocks)
 - rust-lang/rust#143272 (Upgrade the `fortanix-sgx-abi` dependency)
 - rust-lang/rust#143585 (`loop_match`: suggest extracting to a `const` item)
 - rust-lang/rust#143698 (Fix unused_parens false positive)
 - rust-lang/rust#143859 (Guarantee 8 bytes of alignment in Thread::into_raw)
 - rust-lang/rust#144160 (tests: debuginfo: Work around or disable broken tests on powerpc)
 - rust-lang/rust#144412 (Small cleanup: Use LocalKey<Cell> methods more)
 - rust-lang/rust#144431 (Disable has_reliable_f128_math on musl targets)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-26 10:12:14 +00:00
Trevor Gross
39141d01f1 Rollup merge of #144431 - Gelbpunkt:f128-math-musl, r=petrochenkov,tgross35
Disable has_reliable_f128_math on musl targets

musl does not implement the symbols required by rustc for f128 maths. Disable the associated cfg for all musl targets and adjust the tests accordingly.

Closes rust-lang/rust#144423
2025-07-26 02:19:31 -05:00
Trevor Gross
0f557abcfd Rollup merge of #144160 - Gelbpunkt:debuginfo-tests-ppc, r=oli-obk
tests: debuginfo: Work around or disable broken tests on powerpc

f16 support for PowerPC has issues in LLVM, therefore we need a small workaround to prevent LLVM from emitting symbols that don't exist for PowerPC yet.

It also appears that rust-lang/rust#128973 applies to PowerPC targets as well, though I've only tested 64-bit Linux targets.
2025-07-26 02:19:30 -05:00
Trevor Gross
75ed6de1ee Rollup merge of #143698 - benschulz:unused-parens-2, r=lcnr,compiler-errors
Fix unused_parens false positive

Resolves rust-lang/rust#143653.

The "no bounds exception" was indiscriminately set to `OneBound` for referents and pointees. However, if the reference or pointer type itself appears in no-bounds position, any constraints it has must be propagated.

```rust
// unused parens: not in no-bounds position
fn foo(_: Box<(dyn Send)>) {}

// unused parens: in no-bounds position, but one-bound exception applies
fn bar(_: Box<dyn Fn(&u32) -> &(dyn Send)>) {}

// *NOT* unused parens: in no-bounds position, but no exceptions to be made
fn baz(_: Box<dyn Fn(&u32) -> &(dyn Send) + Send>) {}
```
2025-07-26 02:19:28 -05:00
Trevor Gross
d8f4ceb8c0 Rollup merge of #143585 - folkertdev:loop-match-suggest-const-block, r=oli-obk
`loop_match`: suggest extracting to a `const` item

tracking issue: https://github.com/rust-lang/rust/issues/132306
fixes https://github.com/rust-lang/rust/issues/143310
fixes https://github.com/rust-lang/rust/issues/143936
2025-07-26 02:19:28 -05:00
Trevor Gross
33ed3fc07f Rollup merge of #140871 - Amanieu:naked-asm-label, r=compiler-errors
Don't lint against named labels in `naked_asm!`

Naked functions are allowed to define global labels, just like `global_asm!`.
2025-07-26 02:19:26 -05:00
Trevor Gross
6b1b68f4ee Rollup merge of #144356 - GuillaumeGomez:gcc-ignore-tests, r=jieyouxu
Add `ignore-backends` annotations in failing GCC backend ui tests

Follow-up of https://github.com/rust-lang/rust/pull/144125.

In the GCC backend, we don't support all ui tests yet and we have a list of tests we currently ignore available [here](https://github.com/rust-lang/rustc_codegen_gcc/blob/master/tests/failing-ui-tests.txt).

This PR adds the `ignore-backends` annotations to the corresponding ui tests.

The second commit is a fix to compiletest, complaining about `ignore-backends`.

r? ```@jieyouxu```
2025-07-26 01:15:08 -05:00
Trevor Gross
a262dadc40 Rollup merge of #144341 - CaiWeiran:const-vector_test, r=wesleywiser
Enable const-vector.rs test on RISC-V (riscv64)

This PR replaces [#144283](https://github.com/rust-lang/rust/pull/144283) to resolve merge conflicts.

This PR adds support for running the `tests/codegen/const-vector.rs` test on the RISC-V (riscv64) architecture.

Previously, this test would fail on RISC-V targets due to architecture-specific code generation issues. This patch modifies the test to ensure compatibility while preserving its intent.

The change has been tested locally using `./x test` on a riscv64 target, and the test now passes as expected.

### Notes:
- This change is scoped specifically to improve RISC-V compatibility.
- It does not affect behavior or test results on other architectures.
2025-07-26 01:15:07 -05:00
Trevor Gross
e30017ba3e Rollup merge of #144339 - CaiWeiran:dwarf-mixed-versions-lto_test, r=wesleywiser
Enable dwarf-mixed-versions-lto.rs test on RISC-V (riscv64)

This PR replaces [#144284](https://github.com/rust-lang/rust/pull/144284) to resolve merge conflicts.

This PR adds support for running the `tests/assembly/dwarf-mixed-versions-lto.rs` test on the RISC-V (riscv64) architecture.

Previously, this test would fail on RISC-V targets due to architecture-specific code generation issues. This patch modifies the test to ensure compatibility while preserving its intent.

The change has been tested locally using `./x test` on a riscv64 target, and the test now passes as expected.

### Notes:
- This change is scoped specifically to improve RISC-V compatibility.
- It does not affect behavior or test results on other architectures.
2025-07-26 01:15:06 -05:00
Trevor Gross
72e3767380 Rollup merge of #144201 - estebank:suggest-clone, r=SparrowLii
Mention type that could be `Clone` but isn't in more cases

When encountering a moved value of a type that isn't `Clone` because of unmet obligations, but where all the unmet predicates reference crate-local types, mention them and suggest cloning, as we do in other cases already:

```
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
   |
note: if `Foo` implemented `Clone`, you could clone the value
  --> f111.rs:4:1
   |
4  | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- you could clone this value
```

CC rust-lang/rust#68119.
2025-07-26 01:15:05 -05:00
Trevor Gross
9c13f4fb20 Rollup merge of #144089 - Oneirical:uncountable-integer-1, r=jieyouxu
Rehome 35 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`

rust-lang/rust#143902 divided into smaller, easier to review chunks.

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

The URL addition at the end, as well as moving around the auxiliary files and editing the `stderr` files with the new filename, were done using a Python script.

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-07-26 01:15:04 -05:00
Jens Reidel
53018dc2bc Disable has_reliable_f128_math on musl targets
musl does not implement the symbols required by std for f128 maths.
Disable the associated cfg for all musl targets and adjust the tests
accordingly.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-26 07:01:55 +02:00
Zalathar
2b17897092 Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen"
This reverts commit f877aa7d14.
2025-07-26 11:14:40 +10:00
Amanieu d'Antras
1f4561b63d Don't lint against named labels in naked_asm!
Naked functions are allowed to define global labels, just like
`global_asm!`.
2025-07-26 00:42:21 +01:00
Camille GILLOT
7c6496145f Check statics' type in type_of. 2025-07-25 23:39:26 +00:00
Camille GILLOT
ec8146477e Look at layout for completeness. 2025-07-25 23:07:31 +00:00
Joel Wejdenstål
a448837045 Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend. 2025-07-26 01:02:29 +02:00
Folkert de Vries
730d33dd64 loop_match: suggest extracting to a const item
if the expression cannot be evaluated in a straightforward way
2025-07-26 00:10:56 +02:00
Guillaume Gomez
272513868f Update ui tests with new macro early erroring 2025-07-25 23:46:28 +02:00
Guillaume Gomez
5dddba5084 Add missing NOTE annotations in tests/ui/macros/trace-macro.rs 2025-07-25 23:46:28 +02:00
beepster4096
ccc2f78c37 add //@ needs-unwind to test 2025-07-25 13:42:45 -07:00
Jonas Platte
25ed28823a Update mir-opt expected output for matches! macro 2025-07-25 22:34:55 +02:00
Jakub Beránek
4ef18ab062 Allow pretty printing paths with -Zself-profile-events=args 2025-07-25 22:24:21 +02:00
beepster4096
c6d740d37e async drop tests for box 2025-07-25 13:19:43 -07:00
beepster4096
dad982633c fix box destructor generation 2025-07-25 13:19:43 -07:00
Waffle Lapkin
25036f52a0 canonicalize build root in tests/run-make/linker-warning 2025-07-25 22:06:01 +02:00
Esteban Küber
11061831f7 Mention type that could be Clone but isn't in more cases
When encountering a moved value of a type that isn't `Clone` because of unmet obligations, but where all the unmet predicates reference crate-local types, mention them and suggest cloning, as we do in other cases already:

```
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
   |
note: if `Foo` implemented `Clone`, you could clone the value
  --> f111.rs:4:1
   |
4  | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- you could clone this value
```
2025-07-25 18:34:10 +00:00
Kivooeo
e9959aa74e comments 2025-07-25 20:38:54 +05:00
Kivooeo
9f38ca97ea move 28 tests 2025-07-25 20:38:54 +05:00