Commit Graph

502 Commits

Author SHA1 Message Date
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
bors
3ea2fbcb2a Auto merge of #154010 - estebank:issue-42753, r=nnethercote
Suggest using equality comparison instead of pattern matching on non-structural constant in pattern

When encountering a pattern containing a non-structural constant (not marked as `#[derive(PartialEq)]` to make it suitable for pattern matching, `C` in the examples below), we would previously not provide additional guidance. With this PR, the `help` in the following examples are added:

```
error: constant of non-structural type `partial_eq::S` in a pattern
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:16:18
   |
LL |     struct S;
   |     -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL |     const C: S = S;
   |     ---------- constant defined here
...
LL |             Some(C) => {}
   |                  ^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
   |
LL |     impl PartialEq<S> for S {
   |     ^^^^^^^^^^^^^^^^^^^^^^^
help: add a condition to the match arm checking for equality
   |
LL -             Some(C) => {}
LL +             Some(binding) if binding == C => {}
   |
```

```
error: constant of non-structural type `partial_eq::S` in a pattern
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:22:18
   |
LL |     struct S;
   |     -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL |     const C: S = S;
   |     ---------- constant defined here
...
LL |         let Some(C) = Some(S) else { return; };
   |                  ^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
   |
LL |     impl PartialEq<S> for S {
   |     ^^^^^^^^^^^^^^^^^^^^^^^
help: check for equality instead of pattern matching
   |
LL -         let Some(C) = Some(S) else { return; };
LL +         if Some(C) == Some(S) { return; };
   |
```

The suggestion accounts for a few conditions:

 - if the type is not from the local crate and has no `PartialEq` impl, the user can't make it structural, so we don't provide the suggestion
 - regardless of whether the type is local or remote, if it has a manual `PartialEq`, explain that with a derived `PartialEq` you could use equality
 - if the type is local and has no impl, suggest adding a derived `PartialEq` and use equality check instead of pattern matching
 - when suggesting equality, account for `if-let` to suggest chaining (edition dependent), `match` arm with a present `if` check, `match` arm without an existing `if` check
 - when encountering `let-else`, we suggest turning it into an `if` expression instead (this doesn't check for additional bindings beyond the constant, which would suggest incorrect code in some more complex cases).

Fix rust-lang/rust#42753.
2026-03-26 05:30:08 +00:00
cyrgani
9b0be7857a allow incomplete_features in most UI tests 2026-03-21 20:10:07 +00:00
Jonathan Brouwer
d8b5b46b3f Rollup merge of #153828 - Human9000-bit:guard-patterns-thir, r=Nadrieril
Guard patterns: lowering to THIR

This pr implements lowering of guard patterns to THIR

r? @Nadrieril

cc @max-niederman

Tracking issue: rust-lang/rust#129967
2026-03-20 19:36:20 +01:00
Esteban Küber
3f08f6759a Suggest using equality comparison instead of pattern matching on non-strutural constant in pattern
```
error: constant of non-structural type `partial_eq::S` in a pattern
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:16:18
   |
LL |     struct S;
   |     -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL |     const C: S = S;
   |     ---------- constant defined here
...
LL |             Some(C) => {}
   |                  ^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
   |
LL |     impl PartialEq<S> for S {
   |     ^^^^^^^^^^^^^^^^^^^^^^^
help: add a condition to the match arm checking for equality
   |
LL -             Some(C) => {}
LL +             Some(binding) if binding == C => {}
   |
```
2026-03-17 17:54:01 +00:00
ywxt
6a0ce16654 Ignore tests for the parallel frontend 2026-03-17 17:39:59 +08:00
human9000
16fc3012fb Lower guard pattern to THIR 2026-03-17 10:19:23 +05:00
Esteban Küber
8e22bcd7a7 [tiny] Tweak "use of Deref" suggestion message
Surround trait name with backticks.
2026-03-15 02:17:11 +00:00
arferreira
407e421f7f Unify same-span labels in move error diagnostics 2026-03-10 09:35:03 -04:00