summary refs log tree commit diff
path: root/src/test/ui/match
AgeCommit message (Collapse)AuthorLines
2022-06-21Move some tests to more reasonable directoriesCaio-0/+28
2022-06-16 fix one more case of trailing spaceklensy-1/+1
2022-06-03Fully stabilize NLLJack Huey-58/+4
2022-06-03Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebankbors-1/+6
rewrite error handling for unresolved inference vars Pretty much completely rewrites `fn emit_inference_failure_err`. This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments. Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs. r? `@estebank` `@petrochenkov`
2022-06-02add new `emit_inference_failure_err`lcnr-1/+6
2022-05-28Move some tests to more reasonable placesCaio-0/+34
2022-05-22Use revisions for NLL in const-generics and matchJack Huey-10/+22
2022-05-20Move testsCaio-0/+28
2022-04-23Bless pretty-print output.Camille GILLOT-1/+1
2022-04-06regression test for #82866Michael Goulet-0/+23
2022-04-04Format invariance notes with backticksMichael Goulet-2/+2
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-0/+2
2022-03-08Change wording of suggestion to add missing `match` armEsteban Kuber-3/+3
2022-03-08Point at uncovered variants in enum definition in `note` instead of a ↵Esteban Kuber-6/+15
`span_label` This makes the order of the output always consistent: 1. Place of the `match` missing arms 2. The `enum` definition span 3. The structured suggestion to add a fallthrough arm
2022-03-08When finding a match expr with multiple arms that requires more, suggest itEsteban Kuber-1/+4
Given ```rust match Some(42) { Some(0) => {} Some(1) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} Some(1) => {} None | Some(_) => todo!(), } ```
2022-03-08When finding a match expr with a single arm that requires more, suggest itEsteban Kuber-1/+4
Given ```rust match Some(42) { Some(0) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} None | Some(_) => todo!(), } ```
2022-03-08When encountering a match expr with no arms, suggest itEsteban Kuber-3/+8
Given ```rust match Some(42) {} ``` suggest ```rust match Some(42) { None | Some(_) => todo!(), } ```
2022-01-31Bless all pretty printer tests and ui testsDavid Tolnay-3/+2
2022-01-30Bless all pretty printer tests and ui testsDavid Tolnay-10/+8
2022-01-21Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obkMatthias Krüger-2/+2
Ensure that early-bound function lifetimes are always 'local' During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2022-01-01Move `PatKind::Lit` checking from ast_validation to ast loweringAaron Hill-4/+4
Fixes #92074 This allows us to insert an `ExprKind::Err` when an invalid expression is used in a literal pattern, preventing later stages of compilation from seeing an unexpected literal pattern.
2021-12-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-2/+2
During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2021-12-27Visit patterns' literal expressions before binding new identsMichael Goulet-0/+46
2021-11-28suggest cast char -> intcameron-0/+5
2021-11-20Fix for issue 91058Michael Goulet-0/+22
2021-11-18Move some tests to more reasonable directoriesCaio-0/+7
2021-11-06Move some tests to more reasonable directoriesCaio-0/+80
2021-10-13Remove textual span from diagnostic stringOli Scherer-4/+4
2021-09-25Use larger span for adjustments on method callsAaron Hill-1/+1
Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-15Move some tests to more reasonable directoriesCaio-0/+304
2021-08-25Adjust spansNoah Lev-1/+1
* Highlight the whole pattern if it has no fields * Highlight the whole definition if it has no fields * Only highlight the pattern name if the pattern is multi-line * Determine whether a pattern is multi-line based on distance from name to last field, rather than first field
2021-08-21Make E0023 spans even more preciseNoah Lev-5/+3
2021-08-17Make spans for tuple patterns in E0023 more preciseNoah Lev-2/+4
As suggested in #86307.
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-6/+5
2021-08-11Modify structured suggestion outputEsteban Küber-2/+2
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-06-06Add variance-related information to lifetime error messagesAaron Hill-0/+6
2021-05-12Improve error message for non-exhaustive matches on non-exhaustive enumsFabian Wolff-0/+73
2021-05-02add suggestion for unit enum variant when matched with a paternAliénore Bouttefeux-1/+4
2021-04-23add tests for new behaviorSmitty-0/+47
2021-03-19update testsmark-2/+0
2021-01-12Include `..` suggestion if fields are all wildcardsCamelid-0/+4
2021-01-12Always show suggestions in their own subwindowsCamelid-4/+6
2021-01-12Only suggest `..` if more than one field is missingCamelid-10/+4
2021-01-12Specialize `..` help message for all fields vs. the restCamelid-1/+1
2021-01-12Suggest `Variant(..)` if all of the mentioned fields are `_`Camelid-2/+2
2021-01-12Suggest `_` and `..` if a pattern has too few fieldsCamelid-0/+9
For example, this code: struct S(i32, f32); let S(x) = S(0, 1.0); will make the compiler suggest either: let S(x, _) = S(0, 1.0); or: let S(x, ..) = S(0, 1.0);
2020-11-19Regroup many usefulness-related test in the same folderNadrieril-91/+0
2020-11-17Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebankMara Bos-0/+57
Fix exhaustiveness in case a byte string literal is used at slice type fixes #79048
2020-11-17Fix exhaustiveness in case a byte string literal is used at slice typeoli-0/+57
2020-11-14Style nitWho? Me?!-1/+1
Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>