about summary refs log tree commit diff
path: root/tests/ui/match
AgeCommit message (Collapse)AuthorLines
2025-08-29Rollup merge of #145676 - Oneirical:uncountable-integer-9, r=jieyouxuMatthias Krüger-1/+1
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#2 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-27Add test batch 2Oneirical-1/+1
2025-08-27Add test batch 1Oneirical-0/+41
2025-08-17Rehome tests/ui/issues/ tests [5/?]Oneirical-0/+34
2025-08-08Rollup merge of #144400 - Kivooeo:issue3, r=jieyouxuStuart Cook-0/+86
`tests/ui/issues/`: The Issues Strike Back [3/N] Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895. r? ```@jieyouxu```
2025-08-06Rollup merge of #144552 - Oneirical:uncountable-integer-3, r=jieyouxuJakub Beránek-0/+77
Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. 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-05commentsKivooeo-0/+6
2025-08-05moved 35 tests to organized locationsKivooeo-0/+80
2025-08-04Rehome tests/ui/issues/ tests [3/?]Oneirical-0/+77
2025-08-01Rollup merge of #144397 - Kivooeo:issue2, r=jieyouxuRalf Jung-0/+336
`tests/ui/issues/`: The Issues Strike Back [2/N] Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895. r? ``@jieyouxu``
2025-07-31commentsKivooeo-24/+101
2025-07-28expand: Micro-optimize prelude injectionVadim Petrochenkov-2/+2
Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-07-24Rehome tests/ui/issues/ tests [1/?]Oneirical-0/+21
2025-07-24moved 35 tests to organized locationsKivooeo-0/+259
2025-07-23Update uitest stderrsJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-2/+2
2025-04-26Improve HIR pretty-printing of if/else some more.Nicholas Nethercote-4/+4
In the AST the "then" block is represented as a `Block`. In HIR the "then" block is represented as an `Expr` that happens to always be. `ExprKind::Block`. By deconstructing the `ExprKind::Block` to extract the block within, things print properly. For `issue-82392.rs`, note that we no longer print a type after the "then" block. This is good, it now matches how we don't print a type for the "else" block. (Well, we do print a type after the "else" block, but it's for the whole if/else.) Also tighten up some of the pattern matching -- these block expressions within if/else will never have labels.
2025-04-25Improve pretty printing of if/else.Nicholas Nethercote-6/+6
By removing some of the over-indenting. AST pretty printing now looks correct. HIR pretty printing is better, but still over-indents some.
2025-04-25Fix some pretty printing indents.Nicholas Nethercote-4/+4
Indents for `cbox` and `ibox` are 0 or `INDENT_UNIT` (4) except for a couple of places which are `INDENT_UNIT - 1` for no clear reason. This commit changes the three space indents to four spaces.
2025-04-16Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` testsLukas Wirth-0/+2
These emit prelude imports which means they are always edition dependent
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-4/+4
2025-03-21remove `feature(inline_const_pat)`lcnr-30/+11
2025-03-07mir_build: consider privacy when checking for irrefutable patternsMaja Kądziołka-0/+70
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-4/+4
2025-02-14Consider add-prefix replacements tooMichael Goulet-12/+8
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-10/+15
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-04Quickfix `//@ check-pass` is enoughDuskyElf-1/+1
tests/ui/match/enum-and-break-in-match-issue-41213.rs and tests/ui/while/while-let-scope-issue-40235.rs doesn't need to be run.
2025-02-04Rename and Move some UI tests to more suitable subdirsDuskyElf-0/+24
2025-01-23tests: use `needs-subprocess` instead of `ignore-{wasm32,emscripten,sgx}`许杰友 Jieyou Xu (Joe)-5/+5
2025-01-08move the experimental match ergonomics tests to be with the other rfc 3627 testsdianne-1034/+0
2025-01-07make experimental pattern typing features mutually exclusivedianne-180/+11
This aims to reduce the complexity needed in the boolean logic for telling which rules we're using to type patterns. If we still want the functionality this removes, we can re-add it later, after some cleanup to pattern typing.
2024-12-31Rollup merge of #133486 - dianne:fix-move-error-suggestion, r=estebankTrevor Gross-3/+4
borrowck diagnostics: make `add_move_error_suggestions` use the HIR rather than `SourceMap` This PR aims to fix #132806 by rewriting `add_move_error_suggestions`[^1]. Previously, it manually scanned the source text to find a leading `&`, which isn't always going to produce a correct result (see: that issue). Admittedly, the HIR visitor in this PR introduces a lot of boilerplate, but hopefully the logic at its core isn't too complicated (I go over it in the comments). I also tried a simpler version that didn't use a HIR visitor and suggested adding `ref` always, but the `&ref x` suggestions really didn't look good. As a bonus for the added complexity though, it's now able to produce nice `&`-removing suggestions in more cases. I tried to do this such that it avoids edition-dependent checks and its suggestions can be applied together with those from the match ergonomics 2024 migration lint. I haven't added tests for that since the details of match ergonomics 2024 are still being sorted out, but I can try if desired once that's finalized. [^1]: In brief, it fires on patterns where users try to bind by-value in such a way that moves out of a reference to a non-Copy type (including slice references with non-copy elements). The suggestions are to change the binding's mode to be by-reference, either by removing[^2] an enclosing `&`/`&mut` or adding `ref` to the binding. [^2]: Incidentally, I find the terminology of "consider removing the borrow" a bit confusing for a suggestion to remove a `&` pattern in order to make bindings borrow rather than move. I'm not sure what a good, concise way to explain that would be though, and that should go in a separate PR anyway.
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-6/+3
span rendering
2024-12-12Tweak multispan renderingEsteban Küber-2/+1
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-04Add more context to fall-through "const pattern of non-structural type" errorEsteban Küber-1/+3
Point at types that need to be marked with `#[derive(PartialEq)]`. We use a visitor to look at a type that isn't structural, looking for all ADTs that don't derive `PartialEq`. These can either be manual `impl PartialEq`s or no `impl` at all, so we differentiate between those two cases to provide more context to the user. We also only point at types and impls from the local crate, otherwise show only a note. ``` error: constant of non-structural type `&[B]` in a pattern --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | LL | struct B(i32); | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns LL | LL | const A: &[B] = &[]; | ------------- constant defined here ... LL | A => (), | ^ constant of non-structural type | = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details ```
2024-12-04Add context to fall-through "const pattern of non-structural type" errorEsteban Küber-0/+3
Unify wording with the regular non-structural type error.
2024-12-04Reword message for non-structural type constant in patternEsteban Küber-2/+2
2024-12-04Specify type kind of constant that can't be used in patternsEsteban Küber-2/+2
``` error: trait object `dyn Send` cannot be used in patterns --> $DIR/issue-70972-dyn-trait.rs:6:9 | LL | const F: &'static dyn Send = &7u32; | -------------------------- constant defined here ... LL | F => panic!(), | ^ trait object can't be used in patterns ```
2024-12-04Tweak output of some const pattern errorsEsteban Küber-1/+1
- Add primary span labels. - Point at const generic parameter used as pattern. - Point at statics used as pattern. - Point at let bindings used in const pattern.
2024-12-04On `const` pattern errors, point at the `const` item definitionEsteban Küber-0/+6
Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition: ``` error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { | ------------- LL | const X: EFoo; | ------------- constant defined here ... LL | A::X => println!("A::X"), | ^^^^ ```
2024-11-25`add_move_error_suggestions`: use a HIR visitor rather than `SourceMap`dianne-3/+4
2024-11-23Update tests for new TRPL chapter orderChris Krycho-2/+2
2024-11-22Stabilize the 2024 editionEric Huss-74/+68
2024-11-17Point at const when intended binding fall-through pattern is a constEsteban Küber-0/+37
``` error[E0004]: non-exhaustive patterns: `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered --> $DIR/intended-binding-pattern-is-const.rs:2:11 | LL | match 1 { | ^ patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered LL | x => {} | - this pattern doesn't introduce a new catch-all binding, but rather pattern matches against the value of constant `x` | = note: the matched value is of type `i32` note: constant `x` defined here --> $DIR/intended-binding-pattern-is-const.rs:7:5 | LL | const x: i32 = 4; | ^^^^^^^^^^^^ help: if you meant to introduce a binding, use a different name | LL | x_var => {} | ++++ help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL | x => {}, i32::MIN..=3_i32 | 5_i32..=i32::MAX => todo!() | ++++++++++++++++++++++++++++++++++++++++++++++++ ```
2024-07-05Match ergonomics 2024: test type inferenceJules Bertholet-9/+87
2024-07-05Match ergonomics 2024: `&` matches `&mut` on old editionsJules Bertholet-0/+15
2024-07-05Rename edition 2021 fail testJules Bertholet-10/+10
2024-06-27Implement TC's match ergonomics 2024 proposalJules Bertholet-44/+392
Under gate `ref_pat_eat_one_layer_2024_structural`. Enabling `ref_pat_eat_one_layer_2024` at the same time allows the union of what the individual gates allow.
2024-06-23Replace `f16` and `f128` pattern matching stubs with real implementationsTrevor Gross-1/+44
This section of code depends on `rustc_apfloat` rather than our internal types, so this is one potential ICE that we should be able to melt now. This also fixes some missing range and match handling in `rustc_middle`.
2024-06-06Rollup merge of #125168 - ↵Matthias Krüger-137/+151
Jules-Bertholet:match-ergonomics-2024-align-with-rfc, r=Nadrieril Match ergonomics 2024: align implementation with RFC - Remove eat-two-layers (`ref_pat_everywhere`) - Consolidate `mut_preserve_binding_mode_2024` into `ref_pat_eat_one_layer_2024` - `&mut` no longer peels off `&` - Apply "no `ref mut` behind `&`" rule on all editions with `ref_pat_eat_one_layer_2024` - Require `mut_ref` feature gate for all mutable by-reference bindings r? ``@Nadrieril`` cc https://github.com/rust-lang/rust/issues/123076 ``@rustbot`` label A-edition-2024 A-patterns