Commit Graph

19780 Commits

Author SHA1 Message Date
Matthias Krüger
2fc94f119a Rollup merge of #142884 - makai410:coroutine-body, r=celinval
StableMIR: Add method to retrieve body of coroutine

It would be handy if we can retrieve body of a coroutine in StableMIR.
2025-06-26 15:47:21 +02:00
Matthias Krüger
a05f2cc44d Rollup merge of #142393 - compiler-errors:nofield, r=petrochenkov
Don't  give APITs names with macro expansion placeholder fragments in it

The `DefCollector` previously called `pprust::ty_to_string` to construct a name for APITs (arg-position impl traits). The `ast::Ty` that was being formatted however has already had its macro calls replaced with "placeholder fragments", which end up rendering like `!()` (or ICEing, in the case of rust-lang/rust#140333, since it led to a placeholder struct field with no name).

Instead, collect the name of the APIT *before* we visit its macros and replace them with placeholders in the macro expander. This makes the implementation a bit more involved, but AFAICT there's no better way to do this since we can't do a reverse mapping from placeholder fragment -> original macro call AST.

Fixes rust-lang/rust#140333
2025-06-26 15:47:20 +02:00
Matthias Krüger
d73bf103b9 Rollup merge of #142285 - workingjubilee:dont-use-bad-assembly, r=nnethercote
tests: Do not run afoul of asm.validity.non-exhaustive in input-stats

This addresses one of the three powerpc64-unknown-linux-musl test failures in https://github.com/rust-lang/rust/issues/142280

I was motivated to cover it myself because technically this is also compile-time UB if we compile a program that has `asm!` with x86-64-specific instructions on another platform. That'll only mean something if this is ever switched to build-pass, or if checking emits object code, but conveniently "nop" is valid assembly on all platforms anyone has implemented Rust codegen for. Even the weird ones LLVM doesn't support, like PA-RISC or Common Intermediate Language.

...except GPUs. Not sure about those.

r? ```@nnethercote```
2025-06-26 15:47:19 +02:00
Matthias Krüger
cbcf183711 Rollup merge of #141648 - GuillaumeGomez:redundant_explicit_links-expansion, r=lolbinarycat
[rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion

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

The problem was that we change the context for the attributes in some cases to get better error output, preventing us to detect if the attribute comes from expansion. Most of the changes are about keeping track of the "does this span comes from expansion" information.

r? ```@Manishearth```
2025-06-26 15:47:18 +02:00
Matthias Krüger
d5d5eb471e Rollup merge of #139594 - compiler-errors:if-cause, r=oli-obk
Simplify `ObligationCauseCode::IfExpression`

This originally started out as an experiment to do less incremental invalidation by deferring the span operations that happen on the good path in `check_expr_if`, but it ended up not helping much (or at least not showing up in our incremental tests).

As a side-effect though, I think the code is a lot cleaner and there are modest diagnostics improvements with overlapping spans, so I think it's still worth landing.
2025-06-26 15:47:16 +02:00
Matthias Krüger
aa8ba54caf Rollup merge of #124595 - estebank:issue-104232, r=davidtwco
Suggest cloning `Arc` moved into closure

```
error[E0382]: borrow of moved value: `x`
  --> $DIR/moves-based-on-type-capture-clause-bad.rs:9:20
   |
LL |     let x = "Hello world!".to_string();
   |         - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL |     thread::spawn(move || {
   |                   ------- value moved into closure here
LL |         println!("{}", x);
   |                        - variable moved due to use in closure
LL |     });
LL |     println!("{}", x);
   |                    ^ value borrowed here after move
   |
   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value before moving it into the closure
   |
LL ~     let value = x.clone();
LL ~     thread::spawn(move || {
LL ~         println!("{}", value);
   |
```

Fix rust-lang/rust#104232.
2025-06-26 15:47:16 +02:00
Oli Scherer
512ff95206 Rename tilde const test files to conditionally const 2025-06-26 13:46:45 +00:00
Oli Scherer
eb7245a864 Change const trait bound syntax from ~const to [const] 2025-06-26 13:46:45 +00:00
León Orell Valerian Liehr
169e81cd59 Move an ACE test out of the GCI directory 2025-06-26 15:42:57 +02:00
bors
3b9d04c62f Auto merge of #142255 - estebank:edition-diagnostic-changes, r=fee1-dead,WaffleLapkin
Add edition checks for some tests that had divergent output

In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while I was looking at something else.
2025-06-26 13:20:16 +00:00
Ralf Jung
3790eff4d4 const validation: properly ignore zero-sized UnsafeCell 2025-06-26 10:20:48 +02:00
Jonathan Brouwer
3d1cee5324 Move mixed export_name/no_mangle check to check_attr.rs and improve the error
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-26 08:50:42 +02:00
Jonathan Brouwer
287d9afce7 Port #[export_name] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-26 08:50:42 +02:00
Michael Goulet
59e1a3cbf5 Simplify IfCause 2025-06-26 03:43:01 +00:00
Urgau
3175fb2490 Bless tests/ui/macros/must-use-in-macro-55516.rs 2025-06-25 23:58:57 +02:00
Urgau
05d3d17248 Fix suggestion spans inside macros for the unused_must_use lint 2025-06-25 23:03:18 +02:00
Jana Dönszelmann
20e47aafcc Rollup merge of #142992 - workingjubilee:dont-validate-naughty-abis, r=jieyouxu
Convert some ABI tests to use `extern "rust-invalid"`
2025-06-25 22:14:56 +02:00
Jana Dönszelmann
da42289cd7 Rollup merge of #142976 - compiler-errors:coerce-ice, r=fee1-dead
Check CoerceUnsized impl validity before coercing

Self-explanatory from the title.

Fixes rust-lang/rust#126982
Fixes rust-lang/rust#131048
Fixes rust-lang/rust#134217
Fixes rust-lang/rust#126269
Fixes rust-lang/rust#138265
2025-06-25 22:14:56 +02:00
Jana Dönszelmann
131a2e47fb Rollup merge of #142200 - Kivooeo:tf8, r=jieyouxu
`tests/ui`: A New Order [8/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.
2025-06-25 22:14:54 +02:00
Jubilee Young
233882128b tests: Do not run afoul of asm.validity.non-exhaustive in input-stats 2025-06-25 13:08:51 -07:00
Esteban Küber
8c3a033d7f Add edition checks for some tests that had divergent output
In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while looking at something else.
2025-06-25 17:02:26 +00:00
Esteban Küber
f1fb323dda Do not use gen as binding name
If we ever start testing every edition, using a new keyword unnecessarily will cause divergent output, so pre-emptively change `gen` into `generator`.
2025-06-25 16:52:31 +00:00
Michael Goulet
8cd3fa04e2 Don't give APITs names with macro expansion placeholder fragments in it 2025-06-25 15:42:11 +00:00
Michael Goulet
87c8aa1ff6 Normalize before computing ConstArgHasType goal 2025-06-25 15:36:59 +00:00
Michael Goulet
8304435793 Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation 2025-06-25 15:32:08 +00:00
LorrensP-2158466
3be0b6b72c update ui/import tests 2025-06-25 15:40:18 +02:00
Jubilee Young
087dabfca7 Sprinkle breadcrumbs around to lead people to the rust-invalid ABI 2025-06-25 00:54:02 -07:00
Jubilee Young
78652b783d tests: specify why extern "rust-invalid" cannot be used in varargs test 2025-06-25 00:54:02 -07:00
Jubilee Young
12d05d868f tests: migrate unsupported-abi-transmute.rs to extern "rust-invalid" 2025-06-25 00:54:02 -07:00
Jubilee Young
586a9d1c25 tests: split out unsupported-in-impls.rs
The cross-build megatest gets extremely conflict-prone, so
start cutting it into smaller pieces.
2025-06-25 00:54:02 -07:00
Jubilee Young
9cfee735f4 move unstable book page and account for it 2025-06-25 00:52:11 -07:00
Jubilee Young
02a00dfbe4 tests: bless s/C-cmse/cmse/ 2025-06-25 00:52:11 -07:00
Jubilee Young
1400e2d9f5 tests: s/C-cmse/cmse/ 2025-06-25 00:52:10 -07:00
Jubilee
0f77e836c6 Rollup merge of #142983 - compiler-errors:taint-invalid-call-abi, r=workingjubilee
Taint body on invalid call ABI

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

I'm not certain if there are any other paths that should be tainted, but they would operate similarly. Perhaps pointer coercion.

Introduces `extern "rust-invalid"` for testing purposes.

r? ```@workingjubilee``` or ```@oli-obk``` (or anyone)
2025-06-24 19:45:36 -07:00
Jubilee
c3816350ef Rollup merge of #142977 - aDotInTheVoid:rustdochtml-targetfeature, r=GuillaumeGomez
rustdoc: Don't mark `#[target_feature]` functions as ⚠

Closes https://github.com/rust-lang/rust/issues/142952
2025-06-24 19:45:34 -07:00
Jubilee
c062c495a0 Rollup merge of #142955 - bjorn3:cg_clif_test_fixes, r=jieyouxu
Couple of test suite fixes for cg_clif

Most of these are required for getting the test suite running with panic=unwind for cg_clif.
2025-06-24 19:45:34 -07:00
Jubilee
b5631095cd Rollup merge of #142934 - nnethercote:tweak-macro-stats, r=petrochenkov
Tweak `-Zmacro-stats` measurement.

It currently reports net size, i.e. size(output) - size(input). After some use I think this is sub-optimal, and it's better to just report size(output). Because for derive macros the input size is always 1, and for attribute macros it's almost always 1.

r? ```@petrochenkov```
2025-06-24 19:45:33 -07:00
Jubilee
4af75b24e4 Rollup merge of #142844 - dpaoliello:short-ice, r=jieyouxu
Enable short-ice for Windows

Works fine for x64 without modifications.

x86 MSVC is still failing.

Addresses item in rust-lang/rust#128602

---

try-job: x86_64-mingw-*
try-job: x86_64-msvc-*
try-job: i686-msvc-*
2025-06-24 19:45:32 -07:00
Jubilee
2ad6272649 Rollup merge of #142825 - jdonszelmann:track-caller, r=oli-obk
Port `#[track_caller]` to the new attribute system

r? ``@oli-obk``

depends on https://github.com/rust-lang/rust/pull/142493

Closes rust-lang/rust#142783

(didn't add a test for this, this situation should simply never come up again, the code was simply wrong. lmk if I should add it, but it won't test something very useful)
2025-06-24 19:45:32 -07:00
Jubilee
adaf340455 Rollup merge of #142768 - scottmcm:avoid-unneeded-bitcast, r=WaffleLapkin
Avoid a bitcast FFI call in transmuting

For things that only change the valid ranges, we can just return the input, rather than making the `LLVMBuildBitCast` call and having *it* then do nothing.

I tried to tweak this a bit more and broke stuff, so I also added some extra tests for that as we apparently didn't have coverage.
2025-06-24 19:45:31 -07:00
Jubilee
891dc0fb09 Rollup merge of #142633 - folkertdev:interrupt-abi-restrict-signature, r=workingjubilee
Error on invalid signatures for interrupt ABIs

We recently added `extern "custom"`, which must have type `fn()`. The various `extern "interrupt"` ABIs impose similar constraints on the signature of functions with that ABI: `x86-interrupt` should not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type.

r? ```@workingjubilee```
2025-06-24 19:45:31 -07:00
Jubilee
f542909d1c Rollup merge of #138780 - trifectatechfoundation:loop_match_attr, r=oli-obk,traviscross
Add `#[loop_match]` for improved DFA codegen

tracking issue: https://github.com/rust-lang/rust/issues/132306
project goal: https://github.com/rust-lang/rust-project-goals/issues/258

This PR adds the `#[loop_match]` attribute, which aims to improve code generation for state machines. For some (very exciting) benchmarks, see https://github.com/rust-lang/rust-project-goals/issues/258#issuecomment-2732965199

Currently, a very restricted syntax pattern is accepted. We'd like to get feedback and merge this now before we go too far in a direction that others have concerns with.

## current state

We accept code that looks like this

```rust
#[loop_match]
loop {
    state = 'blk: {
        match state {
            State::A => {
                #[const_continue]
                break 'blk State::B
            }
            State::B => { /* ... */ }
            /* ... */
        }
    }
}
```

- a loop should have the same semantics with and without `#[loop_match]`: normal `continue` and `break` continue to work
- `#[const_continue]` is only allowed in loops annotated with `#[loop_match]`
- the loop body needs to have this particular shape (a single assignment to the match scrutinee, with the body a labelled block containing just a match)

## future work

- perform const evaluation on the `break` value
- support more state/scrutinee types

## maybe future work

- allow `continue 'label value` syntax, which `#[const_continue]` could then use.
- allow the match to be on an arbitrary expression (e.g. `State::Initial`)
- attempt to also optimize `break`/`continue` expressions that are not marked with `#[const_continue]`

r? ``@traviscross``
2025-06-24 19:45:30 -07:00
Jubilee
4f477427b8 Rollup merge of #135731 - frank-king:feature/pin-borrow, r=eholk,traviscross
Implement parsing of pinned borrows

This PR implements part of #130494.

EDIT: It introduces `&pin mut $place` and `&pin const $place` as sugars for `std::pin::pin!($place)` and its shared reference equivalent, except that `$place` will not be moved when borrowing. The borrow check will be in charge of enforcing places cannot be moved or mutably borrowed since being pinned till dropped.

### Implementation steps:
- [x] parse the `&pin mut $place` and `&pin const $place` syntaxes
- [ ] borrowck of `&pin mut|const`
- [ ] support autoref of `&pin mut|const` when needed
2025-06-24 19:45:29 -07:00
Michael Goulet
e776065164 Taint body on invalid call ABI 2025-06-24 22:43:00 +00:00
Michael Goulet
e245570def Add rust-invalid ABI 2025-06-24 22:34:30 +00:00
bors
3de5b08ef6 Auto merge of #142979 - matthiaskrgr:rollup-szqah4e, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142645 (Also emit suggestions for usages in the `non_upper_case_globals` lint)
 - rust-lang/rust#142657 (mbe: Clean up code with non-optional `NonterminalKind`)
 - rust-lang/rust#142799 (rustc_session: Add a structure for keeping both explicit and default sysroots)
 - rust-lang/rust#142805 (Emit a single error when importing a path with `_`)
 - rust-lang/rust#142882 (Lazy init diagnostics-only local_names in borrowck)
 - rust-lang/rust#142883 (Add impl_trait_in_bindings tests from rust-lang/rust#61773)
 - rust-lang/rust#142943 (Don't include current rustc version string in feature removed help)
 - rust-lang/rust#142965 ([RTE-497] Ignore `c-link-to-rust-va-list-fn` test on SGX platform)
 - rust-lang/rust#142972 (Add a missing mailmap entry)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-24 21:58:31 +00:00
Daniel Paoliello
4c7f0549ba Enable short-ice for Windows 2025-06-24 14:16:23 -07:00
Jana Dönszelmann
f9cdf3fd74 fix 142783 2025-06-24 23:00:31 +02:00
Jana Dönszelmann
5d44fdd972 Rewrite #[track_caller] 2025-06-24 23:00:31 +02:00
bjorn3
f5af05b8f7 Fix circular dependency test to use rustc_std_internal_symbol 2025-06-24 19:44:35 +00:00