rust/tests/ui/pattern
Matthias Krüger a3663577f2
Rollup merge of #135434 - dianne:match-2024-for-edition-2024, r=Nadrieril
Match Ergonomics 2024: update edition 2024 behavior of feature gates

This updates the edition 2024 behavior of the feature gates `ref_pat_eat_one_layer_2024_structural` and `ref_pat_eat_one_layer_2024` to correspond to the left and right typing rules compared [here](https://nadrieril.github.io/typing-rust-patterns/?compare=true&opts2=AQEBAAABAQABAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=rules&do_cmp=true&ty_d=3&style=SequentBindingMode), respectively. I'll implement the proposed new behavior for editions ≤ 2021 in another PR.

The tests are split up a bit awkwardly for practical reasons, but I've added new tests from 3 places:
- I got tests for where the typing rules differ from the "Compare" tab of the page linked above. These had to be split up based on where the errors are emitted and how rustfixable they are, so they've ended up in different files to keep tidy. Within each file, though, the order of the tests matches the order the typing differences appear in that comparison (as of when this was written).
- I used [this other comparison](https://nadrieril.github.io/typing-rust-patterns/?q=%5B%26mut+%26%28mut+x%29%5D%3A+%26mut+%5B%26CT%5D&compare=true&opts2=AQEBAgABAQEBAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=compare&do_cmp=true&ty_d=3&style=SequentBindingMode) to test the `Deref(EatInner, FallbackToOuter)` rule of the left/"structural"/eat-inner ruleset. These are all in `well-typed-edition-2024.rs`.
- I added some select tests for cases where the new typing rules differ from current stable Rust. I had to be pickier about what I included here, but I tried to make sure each typing rule got some coverage. That said, my approach for these tests was a bit ad-hoc, so I may have missed something.

Relevant tracking issue: #123076

r? ````@ghost````
2025-01-30 12:45:18 +01:00
..
auxiliary Move existing rfc3627 tests to a dedicated folder 2024-09-24 13:45:58 +02:00
bindings-after-at parse guard patterns 2024-11-24 19:42:33 +01:00
deref-patterns add_move_error_suggestions: use a HIR visitor rather than SourceMap 2024-11-25 20:29:04 -08:00
move-ref-patterns Better span for "make binding mutable" suggestion 2024-07-04 02:02:21 +00:00
rfc-3627-match-ergonomics-2024 add tests differing between stable and new rules (with errors on new rules) 2025-01-21 06:39:08 -08:00
rfc-3637-guard-patterns Address review comments 2024-12-07 13:37:35 +01:00
usefulness Remove all dead files inside tests/ui/ 2025-01-27 02:28:04 +01:00
at-in-struct-patterns.rs Parser: better error messages for @ in struct patterns 2024-09-23 02:12:53 +03:00
at-in-struct-patterns.stderr Parser: better error messages for @ in struct patterns 2024-09-23 02:12:53 +03:00
box-pattern-type-mismatch.rs Replace some Option<Diag> with Result<(), Diag> 2024-06-13 06:16:12 +00:00
box-pattern-type-mismatch.stderr Replace some Option<Diag> with Result<(), Diag> 2024-06-13 06:16:12 +00:00
by-move-pattern-binding.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
by-move-pattern-binding.stderr Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
byte-string-inference.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
complexity_limit.rs Add and update tests to use pattern_complexity 2024-03-03 13:10:15 +01:00
complexity_limit.stderr Add and update tests to use pattern_complexity 2024-03-03 13:10:15 +01:00
fn-in-pat.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
fn-in-pat.stderr Update tests for new TRPL chapter order 2024-11-23 08:57:25 -07:00
for-loop-bad-item.rs
for-loop-bad-item.stderr
ignore-all-the-things.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
inc-range-pat.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
incorrect-placement-of-pattern-modifiers.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
incorrect-placement-of-pattern-modifiers.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
incorrect-placement-of-pattern-modifiers.stderr
integer-range-binding.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-6449.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-8351-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-8351-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-10392.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-11577.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-12582.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-14221.rs
issue-14221.stderr Reword the "unreachable pattern" explanations 2024-08-19 21:39:57 +02:00
issue-15080.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-17718-patterns.rs
issue-17718-patterns.stderr
issue-22546.rs Revert "Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix" 2024-08-03 07:57:31 -04:00
issue-22546.stderr Revert "Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix" 2024-08-03 07:57:31 -04:00
issue-27320.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-28992-empty.rs Move some tests 2024-02-09 15:43:08 -03:00
issue-28992-empty.stderr Move some tests 2024-02-09 15:43:08 -03:00
issue-52240.rs
issue-52240.stderr
issue-66270-pat-struct-parser-recovery.rs
issue-66270-pat-struct-parser-recovery.stderr
issue-67037-pat-tup-scrut-ty-diff-less-fields.rs
issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
issue-67776-match-same-name-enum-variant-refs.rs
issue-67776-match-same-name-enum-variant-refs.stderr
issue-72565.rs
issue-72565.stderr Specify type kind of constant that can't be used in patterns 2024-12-04 20:29:36 +00:00
issue-72574-1.rs
issue-72574-1.stderr
issue-72574-2.rs
issue-72574-2.stderr
issue-74539.rs
issue-74539.stderr
issue-74702.rs
issue-74702.stderr
issue-74954.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-80186-mut-binding-help-suggestion.rs
issue-80186-mut-binding-help-suggestion.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
issue-88074-pat-range-type-inference-err.rs
issue-88074-pat-range-type-inference-err.stderr
issue-88074-pat-range-type-inference.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-92074-macro-ice.rs
issue-92074-macro-ice.stderr Change wording 2024-04-29 14:53:38 +02:00
issue-94866.rs
issue-94866.stderr
issue-95878.rs
issue-95878.stderr
issue-106552.rs
issue-106552.stderr Update tests for new TRPL chapter order 2024-11-23 08:57:25 -07:00
issue-106862.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-106862.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-106862.stderr
issue-110508.rs Handle all PatExprs in dead code analysis 2025-01-29 15:45:13 +00:00
issue-115599.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
issue-115599.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
issue-117626.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
missing_lifetime.rs Avoid follow-up errors on erroneous patterns 2024-06-13 06:14:32 +00:00
missing_lifetime.stderr Avoid follow-up errors on erroneous patterns 2024-06-13 06:14:32 +00:00
mut_preserve_binding_mode_2021.rs Gate implicit mutable by-reference bindings behind mut ref 2024-05-15 16:55:54 -04:00
mut_preserve_binding_mode_2021.stderr Fix tests 2024-04-15 23:27:22 -04:00
mut_preserve_binding_mode_2024.rs Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
mut-ref-mut-2021.rs Feature gate 2024-03-27 11:20:28 -04:00
mut-ref-mut-2021.stderr Better span for "make binding mutable" suggestion 2024-07-04 02:02:21 +00:00
no-match-tuple-variant-self-ctor.rs Validate that we're only matching on unit struct for path pattern 2024-03-22 20:53:42 -04:00
no-match-tuple-variant-self-ctor.struct_.stderr Validate that we're only matching on unit struct for path pattern 2024-03-22 20:53:42 -04:00
no-match-tuple-variant-self-ctor.tuple.stderr Validate that we're only matching on unit struct for path pattern 2024-03-22 20:53:42 -04:00
no-patterns-in-args-2.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
no-patterns-in-args-2.stderr Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
no-patterns-in-args.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
no-patterns-in-args.stderr Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
non-constant-in-const-path.rs
non-constant-in-const-path.stderr Tweak output of some const pattern errors 2024-12-04 20:29:36 +00:00
non-structural-match-types.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
non-structural-match-types.stderr Specify type kind of constant that can't be used in patterns 2024-12-04 20:29:36 +00:00
pat-shadow-in-nested-binding.rs
pat-shadow-in-nested-binding.stderr
pat-struct-field-expr-has-type.rs
pat-struct-field-expr-has-type.stderr
pat-tuple-bad-type.rs
pat-tuple-bad-type.stderr
pat-tuple-field-count-cross.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pat-tuple-field-count-cross.stderr
pat-tuple-overfield.rs
pat-tuple-overfield.stderr
pat-tuple-underfield.rs
pat-tuple-underfield.stderr
pat-type-err-formal-param.rs
pat-type-err-formal-param.stderr
pat-type-err-let-stmt.rs
pat-type-err-let-stmt.stderr
patkind-litrange-no-expr.rs Rename PatKind::Lit to Expr 2025-01-08 07:34:59 +00:00
patkind-litrange-no-expr.stderr
patkind-ref-binding-issue-114896.fixed Fix incorrect mutable suggestion information for binding in ref pattern. 2024-03-19 12:28:23 +08:00
patkind-ref-binding-issue-114896.rs Fix incorrect mutable suggestion information for binding in ref pattern. 2024-03-19 12:28:23 +08:00
patkind-ref-binding-issue-114896.stderr More accurate mutability suggestion 2024-07-04 05:36:34 +00:00
patkind-ref-binding-issue-122415.fixed Fix incorrect mutable suggestion information for binding in ref pattern. 2024-03-19 12:28:23 +08:00
patkind-ref-binding-issue-122415.rs Fix incorrect mutable suggestion information for binding in ref pattern. 2024-03-19 12:28:23 +08:00
patkind-ref-binding-issue-122415.stderr More accurate mutability suggestion 2024-07-04 05:36:34 +00:00
pattern-bad-ref-box-order.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pattern-bad-ref-box-order.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pattern-bad-ref-box-order.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
pattern-binding-disambiguation.rs Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
pattern-binding-disambiguation.stderr Update tests for new TRPL chapter order 2024-11-23 08:57:25 -07:00
pattern-error-continue.rs
pattern-error-continue.stderr
pattern-ident-path-generics.rs
pattern-ident-path-generics.stderr
pattern-tyvar-2.rs
pattern-tyvar-2.stderr Change E0369 diagnostic give note information for foreign items. 2024-06-25 10:00:30 +08:00
pattern-tyvar.rs
pattern-tyvar.stderr
patterns-dont-match-nt-statement.rs Don't make pattern nonterminals match statement nonterminals 2024-08-26 18:30:15 -04:00
range-pattern-meant-to-be-slice-rest-pattern.rs Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
range-pattern-meant-to-be-slice-rest-pattern.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
rest-pat-semantic-disallowed.rs
rest-pat-semantic-disallowed.stderr
rest-pat-syntactic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
rest-pat-syntactic.stderr
self-ctor-133272.rs Re-delay a resolve bug 2024-11-21 18:40:36 +08:00
self-ctor-133272.stderr Re-delay a resolve bug 2024-11-21 18:40:36 +08:00
size-and-align.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
skipped-ref-pats-issue-125058.rs Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
skipped-ref-pats-issue-125058.stderr Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
slice-array-infer.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
slice-pattern-refutable.rs
slice-pattern-refutable.stderr Forbid overwriting types in typeck 2024-12-18 15:46:18 +00:00
slice-patterns-ambiguity.rs
slice-patterns-ambiguity.stderr Forbid overwriting types in typeck 2024-12-18 15:46:18 +00:00
slice-patterns-irrefutable.rs
slice-patterns-irrefutable.stderr
slice-patterns-nested.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
struct-parser-recovery-issue-126344.rs report pat no field error no recoverd struct variant 2024-07-11 00:18:47 +08:00
struct-parser-recovery-issue-126344.stderr report pat no field error no recoverd struct variant 2024-07-11 00:18:47 +08:00
struct-pattern-on-non-struct-resolve-error.rs modify test to side-step platform-dependent stderr output 2025-01-08 00:13:43 +00:00
struct-pattern-on-non-struct-resolve-error.stderr modify test to side-step platform-dependent stderr output 2025-01-08 00:13:43 +00:00
struct-pattern-with-missing-fields-resolve-error.rs Add check for missing fields in enum variant pattern 2025-01-08 00:10:16 +00:00
struct-pattern-with-missing-fields-resolve-error.stderr Add check for missing fields in enum variant pattern 2025-01-08 00:10:16 +00:00
suggest-adding-appropriate-missing-pattern-excluding-comments.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
suggest-adding-appropriate-missing-pattern-excluding-comments.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
suggest-adding-appropriate-missing-pattern-excluding-comments.stderr
type_mismatch.rs Avoid follow-up errors on erroneous patterns 2024-06-13 06:14:32 +00:00
type_mismatch.stderr Avoid follow-up errors on erroneous patterns 2024-06-13 06:14:32 +00:00