Commit Graph

773 Commits

Author SHA1 Message Date
Matthias Krüger
4209a4661a Rollup merge of #147165 - Muscraft:subtract-code-offset, r=davidtwco
test: Subtract code_offset from width for ui_testing

`annotate-snippets` does not have a "UI test" mode like `rustc`, [where the code offset is not subtracted from the column width](f34ba774c7/compiler/rustc_errors/src/emitter.rs (L1985-L1987)). This makes it so `annotate-snippets` will shift the output for some very long tests 5 - 7 columns to the left. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I figured it would be best if `rustc` started subtracting the code offset from the width as well.

The first commit exists to keep the test output changes of adding a new line to a test separate from adding the `--diagnostic-width` flag in the second commit. This makes it easier to verify that adding the flag does not affect the test's output.

[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)
2025-10-07 07:04:17 +02:00
yukang
34ad919858 Remove extra space for missing associated type term 2025-10-05 11:11:47 +08:00
Matthias Krüger
2e06dcdbeb Rollup merge of #147245 - karolzwolak:only-replace-intended-bar-not-all-in-pattern, r=lcnr
only replace the intended comma in pattern suggestions

Only suggest to replace the intended comma, not all bars in the pattern.
Fixes rust-lang/rust#143330.
This continues rust-lang/rust#143331, the credit for making the fix goes to `@A4-Tacks.` I just blessed tests and added a regression test.
2025-10-03 21:10:31 +02:00
Karol Zwolak
d1d7b9472a bring back plural 'alternatives' in suggestion message 2025-10-02 20:24:34 +02:00
Scott Schafer
9c6897bd07 test: Subtract code_offset from width for ui_testing 2025-10-02 05:45:16 -06:00
Matthias Krüger
e041b2c078 Rollup merge of #147004 - estebank:ascription-in-pat, r=fee1-dead
Tweak handling of "struct like start" where a struct isn't supported

This improves the case where someone tries to write a `match` expr where the patterns have type ascription syntax. Makes them less verbose, by giving up on the first encounter in the block, and makes them more accurate by only treating them as a struct literal if successfully parsed as such.

Before, encountering something like `match a { b:` would confuse the parser and think everything after `match` *must* be a struct, and if it wasn't it would generate a cascade of unnecessary diagnostics.
2025-10-02 10:27:50 +02:00
Josh Triplett
05c5b87797 mbe: Add parsing tests for unsafe macro rules 2025-10-01 16:19:39 -07:00
Karol Zwolak
a08228d284 bless tests 2025-10-01 22:45:16 +02:00
Guillaume Gomez
a535c7be54 Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
Esteban Küber
43057698c1 Tweak handling of "struct like start" where a struct isn't supported
This improves the case where someone tries to write a `match` expr where the patterns have type ascription syntax. Makes them less verbose, by giving up on the first encounter in the block, and makes them more accurate by only treating them as a struct literal if successfuly parsed as such.
2025-09-24 21:31:23 +00:00
Matthias Krüger
185926c99f Rollup merge of #146434 - folkertdev:c-variadic-inherent-methods, r=workingjubilee
c-variadic: allow c-variadic inherent and trait methods

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

Continuing the work of https://github.com/rust-lang/rust/pull/146342, allow inherent and trait methods to be c-variadic. However, a trait that contains a c-variadic method is no longer dyn-compatible.

There is, presumably, some way to make c-variadic methods dyn-compatible. However currently, we don't have confidence that it'll work reliably: when methods from a `dyn` object are cast to a function pointer, a `ReifyShim` is created. If that shim is c-variadic, it would need to forward the C variable argument list.

That does appear to work, because the `va_list` is not represented in MIR at all in this case, so the registers from the call site are untouched by the shim and can be read by the actual implementation. That just does not seem like a solid implementation.

Also, intuitively, why would c-variadic function, primarily needed for FFI, need to be used with `dyn` objects at all? We can revisit this limitation if a need arises.

r? `@workingjubilee`
2025-09-18 17:20:56 +02:00
Jynn Nelson
2adaa5dae2 Bump rustfix 0.8.1 -> 0.8.7
This commit can be replicated by running
`cargo update -p rustfix --precise 0.8.7 && x test ui --bless`.

---

The reasons this affects UI tests is as follows:
- The UI test suite runs rustc with
    `-Z deduplicate-diagnostics=no --error-format=json`,
  which means that rustc emits multiple errors containing identical
  suggestions. That caused the weird-looking code that had multiple `X: Copy` suggestions.
- Those suggestions are interpreted not by rustc itself, but by the
  `rustfix` library, maintained by cargo but published as a separate
  crates.io library and used by compiletest.
- Sometime between rustfix 0.8.1 and 0.8.7 (probably in cargo 14747, but
  it's hard to tell because rustfix's versioning doesn't match cargo's),
  rustfix got smarter and stopped applying duplicate suggestions.

Update rustfix to match cargo's behavior. Ideally, we would always share
a version of rustfix between cargo and rustc (perhaps with a path
dependency?), to make sure we are testing the behavior we ship. But for
now, just manually update it to match.

Note that the latest version of rustfix published to crates.io is 0.9.1,
not 0.8.7. But 0.9.1 is not the version used in cargo, which is 0.9.3.
Rather than trying to match versions exactly, I just updated rustfix to
the latest in the 0.8 branch.
2025-09-15 10:48:26 -07:00
Jacob Pratt
82bb6d523b Rollup merge of #145896 - Oneirical:uncountable-integer-10, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#3 of Batch #2]

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

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

r? `@jieyouxu`
2025-09-13 03:26:02 -04:00
Oneirical
957fa10d50 Add test batch 3 2025-09-12 14:45:12 -04:00
Folkert de Vries
01e83adc88 c-variadic: allow trait methods to be c-variadic
but a C-variadic method makes a trait dyn-incompatible. That is because
methods from dyn traits, when cast to a function pointer, create a shim.
That shim can't really forward the c-variadic arguments.
2025-09-11 10:27:28 +02:00
Folkert de Vries
fd48528d18 c-variadic: allow inherent methods to be c-variadic 2025-09-11 10:18:48 +02:00
Matthias Krüger
bb45ea3acc Rollup merge of #146342 - folkertdev:c-variadic-errors-take-3, r=workingjubilee
Improve C-variadic error messages: part 2

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

a reimplementation of https://github.com/rust-lang/rust/pull/143546 that builds on https://github.com/rust-lang/rust/pull/146165.

This PR

- disallows coroutines (e.g. `async fn`) from having a `...` argument
- disallows associated functions (both in traits and standard impl blocks) from having a `...` argument
- splits up a generic "ill-formed C-variadic function" into specific errors about using an incorrect ABI, not specifying an ABI, or missing the unsafe keyword

C-variadic coroutines probably don't make sense? C-variadic functions are for FFI purposes, combining that with async functions seems weird.

For associated functions, we're just cutting scope. It's probably fine, but it's probably better to explicitly allow it. So for now, at least give a more targeted error message.

Made to be reviewed commit-by-commit.

cc `@workingjubilee`
r? compiler
2025-09-10 20:29:10 +02:00
Folkert de Vries
9196844f0d c-variadic: reject functions with unsupported extern ABI 2025-09-09 21:38:38 +02:00
Folkert de Vries
0c96200f26 c-variadic: reject non-unsafe functions 2025-09-09 21:30:38 +02:00
Matthias Krüger
12e548704e Rollup merge of #145463 - jieyouxu:error-suffix, r=fmease
Reject invalid literal suffixes in tuple indexing, tuple struct indexing, and struct field name position

Tracking issue: rust-lang/rust#60210
Closes rust-lang/rust#60210

## Summary

Bump the ["suffixes on a tuple index are invalid" non-lint pseudo future-incompatibility warning (#60210)][issue-60210][^non-lint] to a **hard error** across all editions, rejecting the remaining carve outs from accidentally accepted invalid suffixes since Rust **1.27**.

- We accidentally accepted invalid suffixes in tuple indexing positions in Rust **1.27**. Originally reported at https://github.com/rust-lang/rust/issues/59418.
- We tried to hard reject all invalid suffixes in https://github.com/rust-lang/rust/pull/59421, but unfortunately it turns out there were proc macros accidentally relying on it: https://github.com/rust-lang/rust/issues/60138.
- We temporarily accepted `{i,u}{32,size}` in https://github.com/rust-lang/rust/pull/60186 (the "*carve outs*") to mitigate *immediate* ecosystem impact, but it came with an FCW warning indicating that we wanted to reject it after a few Rust releases.
- Now (1.89.0) is a few Rust releases later (1.35.0), thus I'm proposing to **also reject the carve outs**.
    - `std::mem::offset_of!` stabilized in Rust **1.77.0** happens to use the same "don't expect suffix" code path which has the carve outs, so it also accepted the carve out suffixes. I'm proposing to **reject this case as well**.

## What specifically breaks?

Code that still relied on invalid `{i,u}{32,size}` suffixes being temporarily accepted by rust-lang/rust#60186 as an ecosystem impact mitigation measure (cf. rust-lang/rust#60138). Specifically, the following cases (particularly the construction of these forms in proc macros like reported in rust-lang/rust#60138):

### Position 1: Invalid `{i,u}{32,size}` suffixes in tuple indexing

```rs
fn main() {
    let _x = (42,).0invalid; // Already error, already rejected by #59421
    let _x = (42,).0i8;      // Already error, not one of the #60186 carve outs.
    let _x = (42,).0usize;   // warning: suffixes on a tuple index are invalid
}
```

### Position 2: Invalid `{i,u}{32,size}` suffixes in tuple struct indexing

```rs
fn main() {
    struct X(i32);
    let _x = X(42);
	let _x = _x.0invalid; // Already error, already rejected by #59421
    let _x = _x.0i8;      // Already error, not one of the #60186 carve outs.
    let _x = _x.0usize;   // warning: suffixes on a tuple index are invalid
}
```

### Position 3: Invalid `{i,u}{32,size}` suffixes in numeric struct field names

```rs
fn main() {
    struct X(i32, i32, i32);
    let _x = X(1, 2, 3);
    let _y = X { 0usize: 42, 1: 42, 2: 42 };    // warning: suffixes on a tuple index are invalid
	match _x {
        X { 0usize: 1, 1: 2, 2: 3 } => todo!(), // warning: suffixes on a tuple index are invalid
        _ => {}
    }
}
```

### Position 4: Invalid `{i,u}{32,size}` suffixes in `std::mem::offset_of!`

While investigating the warning, unfortunately I noticed `std::mem::offset_of!` also happens to use the "expect no suffix" code path which had the carve outs. So this was accepted since Rust **1.77.0** with the same FCW:

```rs
fn main() {
    #[repr(C)]
    pub struct Struct<T>(u8, T);

    assert_eq!(std::mem::offset_of!(Struct<u32>, 0usize), 0);
    //~^ WARN suffixes on a tuple index are invalid
}
```

### The above forms in proc macros

For instance, constructions like (see tracking issue rust-lang/rust#60210):

```rs
let i = 0;
quote! { foo.$i }
```

where the user needs to actually write

```rs
let i = syn::Index::from(0);
quote! { foo.$i }
```

### Crater results

Conducted a crater run (https://github.com/rust-lang/rust/pull/145463#issuecomment-3194920383).

- 256af3c72f: genuine regression; "invalid suffix `usize`" in derive macro. Has a ton of other build warnings, last updated 6 years ago.
    - Exactly the kind of intended breakage. Minimized down to 256af3c72f/validates_derive/src/lib.rs (L71-L75), where when interpolation uses `quote`'s `ToTokens` on a `usize` index (i.e. on tuple struct `Tup(())`), the generated suffix becomes `.0usize` (cf. Position 2).
    - Notified crate author of breakage in https://github.com/AmlingPalantir/r4/issues/1.
- Other failures are unrelated or spurious.

## Review remarks

- Commits 1-3 expands the test coverage to better reflect the current situation before doing any functional changes.
- Commit 4 is an intentional **breaking change**. We bump the non-lint "suffixes on a tuple index are invalid" warning into a hard error. Thus, this will need a crater run and a T-lang FCP.

## Tasks

- [x] Run crater to check if anyone is still relying on this being not a hard error. Determine degree of ecosystem breakage.
- [x] If degree of breakage seems acceptable, draft nomination report for T-lang for FCP.
- [x] Determine hard error on Edition 2024+, or on all editions.

## Accompanying Reference update

- https://github.com/rust-lang/reference/pull/1966

[^non-lint]: The FCW was implemented as a *non-lint* warning (meaning it has no associated lint name, and you can't `#![deny(..)]` it) because spans coming from proc macros could not be distinguished from regular field access. This warning was also intentionally impossible to silence. See https://github.com/rust-lang/rust/pull/60186#issuecomment-485581694.

[issue-60210]: https://github.com/rust-lang/rust/issues/60210
2025-09-09 17:32:20 +02:00
Folkert de Vries
2b9fce8c8c c-variadic: reject non-extern functions 2025-09-08 19:18:21 +02:00
Folkert de Vries
a093372e5e disallow c-variadic associated functions (for now)
there is no reason this should not work, really, we're just cutting some scope for now
2025-09-08 18:41:22 +02:00
bors
68baa87ba6 Auto merge of #146165 - folkertdev:c-variadic-errors-take-2, r=lcnr
improve c-variadic error reporting

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

The parts of https://github.com/rust-lang/rust/pull/143546 that don't require any particular knowledge about c-variadic functions.

This prepares the way for rejecting c-variadic functions that are also coroutines, safe functions, or associated functions.
2025-09-08 13:18:04 +00:00
bors
9cd272dc85 Auto merge of #146044 - estebank:issue-88727, r=chenyukang
Suggest parentheses when `match` or `if` expression in binop is parsed as statement

```
error[E0308]: mismatched types
  --> $DIR/expr-as-stmt.rs:81:5
   |
LL |     match () { _ => true } && match () { _ => true };
   |     ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool`
   |
help: parentheses are required to parse this as an expression
   |
LL |     (match () { _ => true }) && match () { _ => true };
   |     +                      +
```

Address the common case from rust-lang/rust#88727. The original parse error is still outstanding, but the cases brought up in the thread are resolved.
2025-09-05 12:23:58 +00:00
Folkert de Vries
8d11719e6c simplify check_c_variadic_type 2025-09-03 18:35:00 +02:00
Guillaume Gomez
ae0e7b97e0 Rollup merge of #144066 - RalfJung:extern-c-variadics, r=workingjubilee
stabilize c-style varargs for sysv64, win64, efiapi, aapcs

This has been split up so the PR now only contains the extended_varargs_abi_support stabilization; "system" has been moved to https://github.com/rust-lang/rust/pull/145954.

**Previous (combined) PR description:**

This stabilizes extern block declarations of variadic functions with the system, sysv64, win64, efiapi, aapcs ABIs. This corresponds to the extended_varargs_abi_support and extern_system_varargs feature gates.

The feature gates were split up since it seemed like there might be further discussion needed for what exactly "system" ABI variadic functions should do, but a [consensus](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553) has meanwhile been reached: they shall behave like "C" functions. IOW, the ABI of a "system" function is (bold part is new in this PR):
- "stdcall" for win32 targets **for non-variadic functions**
- "C" for everything else

This had been previously stabilized *without FCP* in https://github.com/rust-lang/rust/pull/116161, which got reverted in https://github.com/rust-lang/rust/pull/136897. There was also a "fun" race condition involved with the system ABI being [added](https://github.com/rust-lang/rust/pull/119587) to the list of variadic-supporting ABIs between the creation and merge of rust-lang/rust#116161.

There was a question raised [here](https://github.com/rust-lang/rust/pull/116161#issuecomment-1983829513) whether t-lang even needs to be involved for a change like this. Not sure if that has meanwhile been clarified? The behavior of the "system" ABI (a Rust-specific ABI) definitely feels like t-lang territory to me.

Fixes rust-lang/rust#100189
Cc `@rust-lang/lang`

# Stabilization report

> ## General design

>  ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

AFAIK there is no RFC. The tracking issues are
- https://github.com/rust-lang/rust/issues/100189
- https://github.com/rust-lang/rust/issues/136946

>  ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

The only controversial point is whether "system" ABI functions should support variadics.
- Pro: This allows crates like windows-rs to consistently use "system", see e.g. https://github.com/microsoft/windows-rs/issues/3626.
- Cons: `@workingjubilee` had some implementation concerns, but I think those have been [resolved](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553). EDIT: turns out Jubilee still has concerns (she mentioned that in a DM); I'll let her express those.

Note that "system" is already a magic ABI we introduced to "do the right thing". This just makes it do the right thing in more cases. In particular, it means that on Windows one can almost always just do
```rust
extern "system" {
  // put all the things here
}
```
and it'll do the right thing, rather than having to split imports into non-varargs and varargs, with the varargs in a separate `extern "C"` block (and risking accidentally putting a non-vararg there).

(I am saying "almost" always because some Windows API functions actually use cdecl, not stdcall, on x86. Those of course need to go in `extern "C"` blocks.)

> ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

Actually defining variadic functions in Rust remains unstable, under the [c_variadic feature gate](https://github.com/rust-lang/rust/issues/44930).

> ## Has a Call for Testing period been conducted? If so, what feedback was received?
>
> Does any OSS nightly users use this feature? For instance, a useful indication might be "search <grep.app> for `#![feature(FEATURE_NAME)]` and had `N` results".

There was no call for testing.

A search brings up https://github.com/rust-osdev/uefi-rs/blob/main/uefi-raw/src/table/boot.rs using this for "efiapi". This doesn't seem widely used, but it is an "obvious" gap in our support for c-variadics.

> ## Implementation quality

All rustc does here is forward the ABI to LLVM so there's lot a lot to say here...

> ### Summarize the major parts of the implementation and provide links into the code (or to PRs)
>
> An example for async closures: <https://rustc-dev-guide.rust-lang.org/coroutine-closures.html>.

The check for allowed variadic ABIs is [here](9c870d30e2/compiler/rustc_hir_analysis/src/lib.rs (L109-L126)).

The special handling of "system" is [here](c24914ec83/compiler/rustc_target/src/spec/abi_map.rs (L82-L85)).

> ### Summarize existing test coverage of this feature
>
> Consider what the "edges" of this feature are.  We're particularly interested in seeing tests that assure us about exactly what nearby things we're not stabilizing.
>
> Within each test, include a comment at the top describing the purpose of the test and what set of invariants it intends to demonstrate. This is a great help to those reviewing the tests at stabilization time.
>
> - What does the test coverage landscape for this feature look like?
>   - Tests for compiler errors when you use the feature wrongly or make mistakes?
>   - Tests for the feature itself:
>       - Limits of the feature (so failing compilation)
>       - Exercises of edge cases of the feature
>       - Tests that checks the feature works as expected (where applicable, `//@ run-pass`).
>   - Are there any intentional gaps in test coverage?
>
> Link to test folders or individual tests (ui/codegen/assembly/run-make tests, etc.).

Prior PRs add a codegen test for all ABIs and tests actually calling extern variadic functions for sysv64 and win64:
- https://github.com/rust-lang/rust/pull/144359
- https://github.com/rust-lang/rust/pull/144379

We don't have a way of executing uefi target code in the test suite, so it's unclear how to fully test efiapi. aapcs could probably be done? (But note that we have hardly an such actually-calling-functions tests for ABI things, we almost entirely rely on codegen tests.)

The test ensuring that we do *not* stabilize *defining* c-variadic functions is `tests/ui/feature-gates/feature-gate-c_variadic.rs`.

> ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

None that I am aware of.

> ### What FIXMEs are still in the code for that feature and why is it ok to leave them there?

None that I am aware of.

> ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization

`@Soveu` added sysv64, win64, efiapi, aapcs to the list of ABIs that allow variadics, `@beepster4096` added system.  `@workingjubilee` recently refactored the ABI handling in the compiler, also affecting this feature.

> ### Which tools need to be adjusted to support this feature. Has this work been done?
>
> Consider rustdoc, clippy, rust-analyzer, rustfmt, rustup, docs.rs.

Maybe RA needs to be taught about the new allowed ABIs? No idea how precisely they mirror what exactly rustc accepts and rejects here.

> ## Type system and execution rules

> ### What compilation-time checks are done that are needed to prevent undefined behavior?
>
>  (Be sure to link to tests demonstrating that these tests are being done.)

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### Does the feature's implementation need checks to prevent UB or is it sound by default and needs opt in in places to perform the dangerous/unsafe operations? If it is not sound by default, what is the rationale?

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### Can users use this feature to introduce undefined behavior, or use this feature to break the abstraction of Rust and expose the underlying assembly-level implementation? (Describe.)

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### What updates are needed to the reference/specification? (link to PRs when they exist)

- https://github.com/rust-lang/reference/pull/1936

> ## Common interactions

> ### Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?

No.

> ### What other unstable features may be exposed by this feature?

None.
2025-09-02 17:08:52 +02:00
Ralf Jung
f6d55aea2c stabilize extended_varargs_abi_support 2025-09-02 08:48:12 +02:00
Esteban Küber
ff60e5c3f3 Suggest parentheses around if-expressions
```
error[E0308]: mismatched types
  --> $DIR/expr-as-stmt-2.rs:15:15
   |
LL |     if true { true } else { false } && true;
   |     ----------^^^^-----------------
   |     |         |
   |     |         expected `()`, found `bool`
   |     expected this to be `()`
   |
help: parentheses are required to parse this as an expression
   |
LL |     (if true { true } else { false }) && true;
   |     +                               +
```
2025-09-02 00:02:16 +00:00
Esteban Küber
f5b5e67f0f More targeted parentheses suggestion for match statement intended as expression
```
error[E0308]: mismatched types
  --> $DIR/expr-as-stmt.rs:69:5
   |
LL |     match () { () => 1 } + match () { () => 1 }
   |     ^^^^^^^^^^^^^^^^^^^^ expected `()`, found integer
   |
help: parentheses are required to parse this as an expression
   |
LL |     (match () { () => 1 }) + match () { () => 1 }
   |     +                    +
```
2025-08-31 01:43:57 +00:00
Esteban Küber
a7e32a5319 Provide suggestion when encountering match () { () => 1 } + match () { () => 1 }
```
error[E0308]: mismatched types
  --> $DIR/expr-as-stmt.rs:69:5
   |
LL |     match () { () => 1 } + match () { () => 1 }
   |     ^^^^^^^^^^^^^^^^^^^^ expected `()`, found integer
   |
help: consider using a semicolon here
   |
LL |     match () { () => 1 }; + match () { () => 1 }
   |                         +
help: alternatively, parentheses are required to parse this as an expression
   |
LL |     (match () { () => 1 }) + match () { () => 1 }
   |     +                    +
```

Parentheses are needed for the `match` to be unambiguously parsed as an expression and not a statement when chaining with binops that are also unops.
2025-08-31 00:42:58 +00:00
Matthias Krüger
e15744e7a4 Rollup merge of #145675 - Oneirical:uncountable-integer-8, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#1 of Batch #2]

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

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

r? `@jieyouxu`
2025-08-29 12:37:30 +02:00
Jonathan Brouwer
e0bdc46d94 Update uitest stderr
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-28 20:05:04 +02:00
Jonathan Brouwer
2c7dfa91b5 Add another case to the bad-lit-suffixes test
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-28 19:23:55 +02:00
Stuart Cook
2fae59ac96 Rollup merge of #144864 - Muscraft:no-source-fixes, r=jieyouxu
No source fixes

This PR started as a fix for a rendering bug that [got noticed in #143661](https://github.com/rust-lang/rust/pull/143661#discussion_r2199109530), but turned into a fix for any rendering bugs related to files with no source.
- Don't add an end column separator after a file with no source
- Add column separator before secondary messages with no source
- Render continuation between no source labels

Before
```
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap`
   ╭▸ $DIR/multi-suggestion.rs:17:13
   │
LL │     let _ = std::collections::HashMap();
   │             ━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
   │
   ╰ note: `std::collections::HashMap` defined here
   ╰╴
note: constructor is not visible here due to private fields
   ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
   │
   ╰ note: private field
   │
   ╰ note: private field
```

After
```
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap`
   ╭▸ $DIR/multi-suggestion.rs:17:13
   │
LL │     let _ = std::collections::HashMap();
   │             ━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ╰╴
   ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
   │
   ╰ note: `std::collections::HashMap` defined here
note: constructor is not visible here due to private fields
   ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
   │
   ├ note: private field
   │
   ╰ note: private field
```

Note: This PR also makes it so `rustc` and `annotate-snippets` match in these cases
2025-08-28 23:10:34 +10:00
Jonathan Brouwer
7db1840569 Changes to the uitests
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-27 20:25:18 +02:00
Oneirical
2e659f5894 Add test batch 1 2025-08-27 00:23:26 -04:00
Scott Schafer
93d16c5100 fix: Add col separator before secondary messages with no source 2025-08-26 15:15:17 -06:00
Jacob Pratt
2dbd411d22 Rollup merge of #144897 - fee1-dead-contrib:raw_lifetimes_printing, r=fmease
print raw lifetime idents with r#

This replaces rust-lang/rust#143185 and fixes rust-lang/rust#143150

cc ``@fmease``
2025-08-22 22:00:47 -04:00
Jacob Pratt
85c9af57f4 Rollup merge of #137396 - compiler-errors:param-default, r=fmease
Recover `param: Ty = EXPR`

Fixes #137310

Pretty basic recovery here, but better than giving an unexpected token error.
2025-08-22 22:00:44 -04:00
Michael Goulet
6caa586f57 Recover param: Ty = EXPR 2025-08-22 21:45:28 +02:00
Jonathan Brouwer
ec5b2cce8e Updated uitests for new parser 2025-08-22 08:58:45 +02:00
Deadbeef
4970127c33 address review comments 2025-08-22 13:16:44 +08:00
Deadbeef
30bb7045d6 don't print invalid labels with r# 2025-08-22 12:58:37 +08:00
Jacob Pratt
1e6df58e77 Rollup merge of #140794 - karolzwolak:allow-unused-doc-65464, r=davidtwco
mention lint group in default level lint note

### Summary

This PR updates lint diagnostics so that default-level notes now mention the lint group they belong to, if any.
Fixes: rust-lang/rust#65464.

### Example

```rust
fn main() {
    let x = 5;
}
```

Before:

```
= note: `#[warn(unused_variables)]` on by default
```

After:

```
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
```

### Unchanged Cases

Messages remain the same when the lint level is explicitly set, e.g.:

* Attribute on the lint `#[warn(unused_variables)]`:

  ```
  note: the lint level is defined here
  LL | #[warn(unused_variables)]
     |        ^^^^^^^^^^^^^^^^
  ```
* Attribute on the group `#[warn(unused)]:`:

  ```
  = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
  ```
* CLI option `-W unused`:

  ```
  = note: `-W unused-variables` implied by `-W unused`
  = help: to override `-W unused` add `#[allow(unused_variables)]`
  ```
* CLI option `-W unused-variables`:

  ```
  = note: requested on the command line with `-W unused-variables`
  ```
2025-08-20 00:45:53 -04:00
Karol Zwolak
d14b83e378 bless tests with new lint messages 2025-08-19 21:27:10 +02:00
许杰友 Jieyou Xu (Joe)
b638266f23 Rollup merge of #145474 - fmease:paren-use-bounds-fix, r=fee1-dead
Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups

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

First commit fixes the issue, second one performs some desperately needed cleanups.

The fix shouldn't be a breaking change because IINM the parser always ensures that all brackets are balanced (via a buffer of brackets). Meaning even though we used to accept `(use<>` as a valid precise capturing list, it was guaranteed that we would fail in the end.
2025-08-19 19:45:33 +08:00
Jieyou Xu
ddd99930f3 Turn invalid index suffixes into hard errors 2025-08-18 21:57:11 +08:00
Jieyou Xu
eb3441b25a Add test coverage for proc-macro invalid tup index suffixes 2025-08-18 21:57:10 +08:00
Jieyou Xu
d7f7443a95 Expand tuple-index-suffix test coverage
Actually, the accidentally accepted invalid suffixes also include tuple
struct indexing positions, struct numeral field name positions. So
before changing anything, first expand test coverage, so we can observe
the effect of bumping the non-lint pseudo-FCW warning into a hard error.
2025-08-18 21:57:09 +08:00
Jieyou Xu
ea44f12f72 Rename and move tuple index suffix regression test
To make it more obvious what it's testing.

This is its own commit to make git blame easier.
2025-08-18 21:57:09 +08:00