Commit Graph

510 Commits

Author SHA1 Message Date
Jonathan Brouwer
07d9787382 Rollup merge of #161180 - GTimothy:detect_missing_binding_available-suggestion, r=mu001999
Detect missing binding available: add a MaybeIncorrect suggestion

When suggesting that a missing binding is available in a pattern but not used, if it is behind a `..` suggest a MaybeIncorrect fix replacing `..` with `{binding}, ..`

This suggestion could be a `tool_only_suggestion`, or a `span_suggestion_hidden`. Other types of suggestions seem a bit too verbose for this simple case.
The `tool_only_suggestion` (first commit) does not add any suggestion in stderr, the `span_suggestion_hidden` (second commit) shows a minimal help line.

This work was extracted from PR https://github.com/rust-lang/rust/pull/156239.
2026-08-25 18:00:07 +02:00
GTimothy
eb186bb745 add suggestion for detect_missing_binding_available_from_pattern
When a pattern has `..` and a matching binding, suggest replacing `..`
with `binding, ..`

bless tests

Co-authored-by: Roland Xu <rcu@live.com>
2026-08-25 14:12:45 +02:00
cyrgani
d86e422962 remove box_patterns from remaining tests 2026-08-25 08:03:22 +00:00
Waffle Lapkin
2b466a3994 bless tests 2026-08-24 19:04:00 +02:00
Waffle Lapkin
046ebb717e remove #![feature(never_type)] from tests 2026-08-24 19:04:00 +02:00
Jacob Pratt
4e637b3c68 Rollup merge of #160279 - ArneshBanerjee:recover-tuple-type-ascription, r=fmease
Recover from tuple patterns with inline element types

If you write the element types inside a tuple pattern:

```rust
let (a: bool, b: u8) = (true, 1);
```

the error you get doesn't really explain the problem:

```
error: expected one of `)`, `,`, `@`, `if`, or `|`, found `:`
 --> src/main.rs:2:11
  |
2 |     let (a: bool, b: u8) = (true, 1);
  |           ^ expected one of `)`, `,`, `@`, `if`, or `|`
```

A let pattern can have a type after it, so now we point out what to do instead:

```
help: to annotate the types of a tuple's elements, write them as a tuple type after the pattern
  |
2 -     let (a: bool, b: u8) = (true, 1);
2 +     let (a, b): (bool, u8) = (true, 1);
  |
```

If an element doesn't have a type written, it just gets `_`, so `(a: bool, b)`
turns into `(a, b): (bool, _)`.

I kept this to let bindings only. That's the case where the pattern doesn't need
a type of its own, so once the types move into the suggestion the rest of the
statement parses fine and you get a single error instead of a pile of follow-up
ones. Match arms, nested patterns and function parameters are left alone.

Closes rust-lang/rust#149246
2026-08-23 05:59:33 -04:00
Arnesh Banerjee
aad8a5a7a3 Address review: recover in all pattern locations, drop extra allocation 2026-08-23 07:07:46 +05:30
mejrs
9ac7293a8a resolver diagnostics: don't swallow labels and point out similar items as a note, not a label 2026-08-13 14:12:34 +02:00
Jacob Pratt
b8e8ffb240 Rollup merge of #159612 - zedddie:gsoc-batch-29-meow, r=Teapot4195
Reorganize `tests/ui/issues` [29/N]

Part of [GSoC'26 project](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Reorganizing.20tests.2Fui.2Fissues)

r? Kivooeo
@Teapot4195
2026-07-23 19:18:43 -04:00
Jacob Pratt
445d6002a8 Rollup merge of #159412 - zedddie:gsoc-batch-26-meow, r=Kivooeo
Reorganize `tests/ui/issues` [26/N]

Part of [GSoC'26 project](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Reorganizing.20tests.2Fui.2Fissues)

r? Kivooeo
@Teapot4195
2026-07-23 19:18:34 -04:00
zedddie
cd9fd520d9 bless batch 2026-07-23 19:57:43 +02:00
Guillaume Gomez
f791d707db Rollup merge of #159504 - RalfJung:generic-in-pat, r=BoxyUwU,Nadrieril
Abort const-eval queries early when there are generics in the type

Since [recently](https://github.com/rust-lang/rust/pull/156977), const validation has a `has_param` check, which means ConstToPat also implicitly has that check. But it seems better to check this again explicitly here rather then rely on an undocumented property of some other component. The new test behaves the same with or without the PR.

I recommend hiding whitespace difference, since rustfmt re-indendet a bunch of stuff.
Fixes https://github.com/rust-lang/rust/issues/150296
r? @BoxyUwU
2026-07-23 00:29:23 +02:00
Jonathan Brouwer
9111027471 Rollup merge of #159707 - RalfJung:dangling-ref-in-pattern, r=WaffleLapkin
fix error when a dangling ref in a ManuallyDrop is used in a pattern

Fixes https://github.com/rust-lang/rust/issues/159701
Cc @rust-lang/wg-const-eval
2026-07-22 18:02:22 +02:00
Ralf Jung
e96b538c05 add test for a sneaky generic in a pattern 2026-07-22 15:35:11 +02:00
Ralf Jung
c22fbbe582 fix error when a dangling ref in a ManuallyDrop is used in a pattern 2026-07-22 15:26:51 +02:00
Jacob Pratt
e1d8ba6e3b Rollup merge of #159307 - TorinAsakura:fix/builtin-attribute-value-diagnostics, r=petrochenkov
Improve cross-namespace name diagnostics

Close rust-lang/rust#86290

Cross-namespace name matches now use the ordinary missing-name diagnostic while preserving its error code and suggestions. The diagnostic adds a note identifying the item found in another namespace, while same-namespace wrong-kind diagnostics remain unchanged.

The UI expectations cover cross-namespace combinations across the resolver suite, including preservation of existing suggestions.
2026-07-20 23:38:00 -04:00
Andrew Ghostuhin
30bc6d2f06 fix: improve missing value diagnostics for built-in attributes 2026-07-21 01:03:16 +03:00
zedddie
3b999caee6 bless batch 2026-07-20 20:27:27 +02:00
zedddie
2851cef01a move batch 2026-07-20 01:59:03 +02:00
Jonathan Brouwer
2f92d1e75e Rollup merge of #159469 - zedddie:gsoc-batch-27-meow, r=Teapot4195
Reorganize `tests/ui/issues` [27/N]

Part of [GSoC'26 project](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Reorganizing.20tests.2Fui.2Fissues)

r? Kivooeo
@Teapot4195
2026-07-19 17:04:34 +02:00
León Orell Valerian Liehr
a4142b7ea5 Apply #[diagnostic::opaque] to macros expanding to built-in syntax 2026-07-18 18:42:03 +02:00
zedddie
ac8a3472ae bless batch 2026-07-17 23:47:37 +02:00
zedddie
87bdc236db move batch 2026-07-17 23:26:13 +02:00
zedddie
75870305c3 move batch 2026-07-16 23:51:04 +02:00
zedddie
ed1dd8831e bless batch 2026-06-18 05:28:05 +02:00
zedddie
3f32f5112b move batch 2026-06-18 05:28:05 +02:00
Jacob Pratt
a3f61b5382 Rollup merge of #157342 - estebank:cycle-error-verbose, r=tiif
Reduce verbosity of cycle errors when possible

When pointing at each step of cycle errors, do not include the code snippet when the note points at the same place as the previous one (by setting the note's span to DUMMY_SP).
2026-06-11 23:15:21 -04:00
Jacob Pratt
dccee42564 Rollup merge of #154543 - chenyukang:yukang-fix-146995-deref-field-suggestion, r=fmease
Fix deref field pattern suggestions and improve error messages

Fixes rust-lang/rust#146995
2026-06-08 16:27:00 -04:00
Daria Sukhonina
30451d6bcd Ignore diagnostic lines with a single "|"
Inconsistency happens when subdiagnostic pads the main diagnostic with
an empty source line (aka "|"). Meanwhile the parallel frontend might
bunch subdiagnostics on a single primary diagnostic, removing padding
from some other one.

Revert "Update reproducibly failing tests when parallel frontend is enabled"

This reverts commit f582193db5.

Apply a test directive format suggested by a reviewer

Bless thine tests
2026-06-08 13:32:41 +03:00
zedddie
eff5e8dd06 bless batch 2026-06-06 21:02:15 +02:00
zedddie
d21aa1c6f4 move batch 2026-06-06 20:58:17 +02:00
Esteban Küber
2c7186a725 Reduce verbosity of cycle errors when possible
When pointing at each step of cycle errors, do not include the code snippet when the note points at the same place as the previous one (by setting the note's span to DUMMY_SP).
2026-06-04 16:10:12 +00:00
Daria Sukhonina
f582193db5 Update reproducibly failing tests when parallel frontend is enabled 2026-05-29 12:29:32 +03:00
Kokoro2336
a09204ad18 fix: missing suggestion for string match.
chore: update .fixed.

fix: suggestion.

Revert irrelevant changes.
2026-05-26 02:01:52 +08:00
yukang
08118c869f Fix deref field pattern suggestions and improve error messages 2026-05-08 15:10:37 +08:00
John Kåre Alsaker
25e018de2d Add better default spans for the Ty impl of QueryKey 2026-05-04 16:56:59 +02:00
Jacob Pratt
1230f74ad5 Rollup merge of #155698 - fmease:no-struct-pat-tuple-index-shorthand, r=mu001999
Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression

Split out of PR rust-lang/rust#154492. This fixes a correctness regression introduced in PR rust-lang/rust#81235 from 2021. Crater was run in my other PR and didn't report any real regressions (https://github.com/rust-lang/rust/pull/154492#issuecomment-4187544786); a rerun has been issued for a few spurious builds (https://github.com/rust-lang/rust/pull/154492#issuecomment-4237077272) but I'm certain it won't find anything either.

This is a theoretical breaking change that doesn't need any T-lang input IMHO since it's such a minute, niche and crystal clear bug that's not worth bothering them with (such a decision is not unprecedented). I'm adding it to the compatibility section of the release notes as is customary.

The Reference doesn't need updating since it didn't adopt this bug and thus accurately describes this part of the grammar as it used to be before 2021-02-23 and as it's meant to be.

The majority of the diff is doc comment additions & necessary UI test restructurings.
2026-04-24 02:42:52 -04:00
Jacob Pratt
b9cf909390 Rollup merge of #155081 - reddevilmidzy:ui-fixme, r=Kivooeo
Move and clean up some ui test

`ui/reserved` -> `ui/keyword`
`ui/deref-patterns` -> `ui/pattern/deref-patterns`
`ui/unknown-unstable-lints` -> `ui/lint/unknown-lints`

Tests related to unknown_lints that were located above lint have also been moved to a subdirectory, and duplicate tests have been deleted.

And delete unnecessary `//@ check-fail`

r? Kivooeo
2026-04-24 02:42:49 -04:00
León Orell Valerian Liehr
07d015e566 Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression 2026-04-23 22:28:00 +02:00
cijiugechu
ffcbfc1cf4 Use singular wording for single _ placeholders in type suggestions 2026-04-20 22:21:51 +08:00
Jonathan Brouwer
b8e88c7f49 Rollup merge of #155062 - ujjwalvishwakarma2006:reorg-tests, r=Kivooeo
Move tests from `tests/ui/issues/` to appropriate directories

In this PR, I am moving the following test from `tests/ui/issues` directory to the appropriate directories, followed by the addition of issue links at the top and reblessing of the stderr files:

| old-name | new-sub-dir | new-name |
|-|-|-|
| `issue-29516.rs` | `auto-traits/` | `distinct-type-tuple-by-negative-impl.rs` |
| `issue-3874.rs` | `binding/` | `ref-in-let-lhs-in-field.rs` |
| `issue-32782.rs` | `feature-gates/` | `feature-gate-check-nested-macro-invocation.rs` |
| `issue-32782.stderr` | `feature-gates/` | `feature-gate-check-nested-macro-invocation.stderr` |
| `issue-5100.rs` | `pattern/` | `match-errors-derived-error-suppression.rs` |
| `issue-5100.stderr` | `pattern/` | `match-errors-derived-error-suppression.stderr` |
| `issue-21033.rs` | `pattern/` | `match-struct-var-having-boxed-field.rs` |

r? Kivooeo
r? Teapot4195
2026-04-13 20:20:04 +02:00
ujjwalVishwakarma2006
9de8c8cf94 Add issue links and blessed error files 2026-04-12 20:43:28 +05:30
ujjwalVishwakarma2006
c9bfc85d1e Move tests to appropriate subdirectories 2026-04-12 20:36:55 +05:30
Redddy
df2fe313d4 Fix format and bless test 2026-04-10 05:40:28 +00:00
Redddy
70af5cf2a3 Move deref-patterns tests to pattern sub directory 2026-04-10 05:40:28 +00:00
Jacob Pratt
1166f31d43 Rollup merge of #155017 - fmease:update-issue-number-unstable_syntax_pre_expansion, r=Kivooeo
Update tracking issue number of future-incompatibility lint `unstable_syntax_pre_expansion`

Issue rust-lang/rust#65860 has never been a proper tracking issue, it has always been a normal issue that reported a pass→fail regression which was subsequently fixed and which elicited a discussion spanning 50 comments. Years later the formerly offending errors were reintroduced as warnings which link to said issue (see section *Pre-History* in issue rust-lang/rust#154045 for details).

A few weeks ago I closed this issue (https://github.com/rust-lang/rust/issues/65860#issuecomment-4083652176) in favor of a new super focused & structured tracking issue, rust-lang/rust#154045. That means people now have to jump through hoops to arrive at the new tracking issue which is less than ideal (it's very likely that this user had to do so: https://github.com/rust-lang/rust/issues/154045#issuecomment-4207339422), let's fix that.

Part of rust-lang/rust#154045.
2026-04-08 23:04:02 -04:00
León Orell Valerian Liehr
2d33b30eb1 Update tracking issue number of future-incompatibility lint unstable_syntax_pre_expansion 2026-04-09 01:08:52 +02:00
Jacob Adam
db8ce5fafb Update results for tests affected by the change 2026-04-07 10:08:49 +01:00
Ralf Jung
7881a31ccf Rollup merge of #152880 - JohnTitor:tweak-assoc-item-note, r=fmease
Tweak incorrect assoc item note

Fix rust-lang/rust#142797
r? @fmease
2026-03-28 13:15:48 +01:00
Yuki Okushi
531631c7ad Make messages more generic 2026-03-28 16:18:11 +09:00