summary refs log tree commit diff
path: root/src/test/ui/pattern
AgeCommit message (Collapse)AuthorLines
2022-10-13Move some tests to more reasonable directoriesCaio-0/+33
2022-10-01bless ui testsMaybe Waffle-4/+4
2022-09-27add a label to struct/enum/union ident nameTakayuki Maeda-0/+2
2022-09-15Remove the let_else feature gate from the testsuiteest31-14/+12
Result of running: rg -l "feature.let_else" src/test/ | xargs sed -s -i "s#^...feature.let_else..\$##" Plus manual tidy fixes.
2022-09-15Remove feature gate from let else suggestionest31-2/+2
The let else suggestion added by 0d92752b8aac53e033541d04fc7d9677d8bca227 does not need a feature gate any more.
2022-09-13Rebase fallout.Camille GILLOT-12/+8
2022-09-08Rollup merge of #101399 - cjgillot:borrowck-binding-span, r=estebankDylan DPC-154/+103
Shrink span for bindings with subpatterns. Bindings with nested patterns (`binding @ pat` syntax) currently point to the full pattern. This PR proposes to shrink the span to stop before the ````@`.``` This makes the diagnostics for move/mutability conflicts clearer, as they not point to the `binding` only, instead of the full pat. r? ```@estebank```
2022-09-06Shrink span for bindings with subpatterns.Camille GILLOT-154/+103
2022-09-03Include enum path in variant suggestionMichael Goulet-180/+180
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-21Note closure kind mismatch causeMichael Goulet-3/+27
2022-08-21Rework point-at-argMichael Goulet-3/+3
2022-08-17Reenable early feature-gates as future-compat warningsChristopher Durham-1/+28
2022-08-09suggest adding an appropriate missing pattern excluding commentsTakayuki Maeda-0/+43
2022-07-09Rollup merge of #99008 - obeis:issue-98974, r=compiler-errorsDylan DPC-4/+16
Adding suggestion for E0530 Closes #98974
2022-07-08Update ui test for the new E0530 suggestionObei Sideg-4/+16
2022-07-07Shorten span for closures.Camille GILLOT-1/+1
2022-07-06use `named_span` in case of tuple variantTakayuki Maeda-6/+6
2022-07-01Auto merge of #98781 - GuillaumeGomez:rollup-798kb8u, r=GuillaumeGomezbors-3/+3
Rollup of 5 pull requests Successful merges: - #97249 (`<details>`/`<summary>` UI fixes) - #98418 (Allow macOS to build LLVM as shared library) - #98460 (Use CSS variables to handle theming) - #98497 (Improve some inference diagnostics) - #98708 (rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests) Failed merges: - #98761 (more `need_type_info` improvements) r? `@ghost` `@rustbot` modify labels: rollup
2022-07-01Only label place where type is needed if span is meaningfulMichael Goulet-3/+3
2022-07-01Shorten def_span for more items.Camille GILLOT-105/+57
2022-06-24improve wording of a suggestionMaybe Waffle-1/+1
2022-06-23Suggest defining variable as mutable on `&mut _` type mismatch in patsMaybe Waffle-0/+5
2022-06-19Be more hygenic with spansMichael Goulet-56/+38
2022-06-19Only omit trailing comma if block doesn't come from macro expansionMichael Goulet-1/+1
2022-06-16bless clippy testsklensy-1/+1
2022-06-16Rollup merge of #97964 - WaffleLapkin:fix_borrow_par_suggestions, ↵Yuki Okushi-1/+5
r=compiler-errors Fix suggestions for `&a: T` parameters I've accidentally discovered that we have broken suggestions for `&a: T` parameters: ```rust fn f(&mut bar: u32) {} fn main() { let _ = |&mut a| (); } ``` ```text error[E0308]: mismatched types --> ./t.rs:1:6 | 1 | fn f(&mut bar: u32) {} | ^^^^^^^^----- | | | | | expected due to this | expected `u32`, found `&mut _` | help: did you mean `bar`: `&u32` | = note: expected type `u32` found mutable reference `&mut _` error[E0308]: mismatched types --> ./t.rs:4:23 | 4 | let _: fn(u32) = |&mut a| (); | ^^^^^-- | | | | | expected due to this | expected `u32`, found `&mut _` | help: did you mean `a`: `&u32` | = note: expected type `u32` found mutable reference `&mut _` ``` It's hard to see, but 1. The help span is overlapping with "expected" spans 2. It suggests `fn f( &u32) {}` (no `mut` and lost parameter name) and `|&u32 ()` (no closing `|` and lost parameter name) I've tried to fix this. r? ``@compiler-errors``
2022-06-10Fix suggestions for `&a: T` parametersMaybe Waffle-1/+5
Previously we were suggesting stuff like `fn f( &u32) {}`
2022-06-10Bless tests.Camille GILLOT-92/+84
2022-06-02add new `emit_inference_failure_err`lcnr-8/+14
2022-05-29Note pattern mismatch coming from for-loop desugaringMichael Goulet-0/+43
2022-05-20Move testsCaio-0/+15
2022-04-27Make [e]println macros eagerly drop temporaries (for backport)David Tolnay-1/+1
2022-04-26Move some tests to more reasonable placesCaio-0/+44
2022-04-16Implementation for 65853Jack Huey-1/+9
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-10Delay a bug when we see SelfCtor in ref patternMichael Goulet-0/+20
2022-03-30Restore `impl Future<Output = Type>` to async blocksMichael Goulet-1/+1
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-1/+8
2022-03-22remove [async output] from impl FutureMichael Goulet-1/+1
2022-03-16Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPCDylan DPC-1/+1
Format core and std macro rules, removing needless surrounding blocks Many of the asserting and printing macros in `core` and `std` are written with prehistoric-looking formatting, like this: https://github.com/rust-lang/rust/blob/335ffbfa547df94ac236f5c56130cecf99c8d82b/library/std/src/macros.rs#L96-L101 In modern Rust style this would conventionally be written as follows instead, always using braces and a trailing semicolon on the macro arms: https://github.com/rust-lang/rust/blob/af53809c874e0afb7be966df4d3cfcaa05277c53/library/std/src/macros.rs#L98-L105 Getting rid of the unneeded braces inside the expansion reduces extraneous indentation in macro-expanded code. For example: ```rust println!("repro {}", true); ``` ```rust // before: { ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); }; ``` ```rust // after: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); ```
2022-03-12Fix rebase conflicts with stderr filesDevin Ragotzy-53/+160
2022-03-12Only filter doc(hidden) fields/variants when not crate localDevin Ragotzy-9/+65
2022-03-12Update output for doc hidden usefulness ui test outputDevin Ragotzy-62/+64
2022-03-12Add struct to doc hidden usefulness ui testsDevin Ragotzy-11/+35
2022-03-12Add struct to stability ui tests in usefulnessDevin Ragotzy-15/+60
2022-03-11Format core and std macro rules, removing needless surrounding blocksDavid Tolnay-1/+1
2022-03-08Do not suggest `let_else` if no bindings would be introducedEsteban Kuber-16/+0
2022-03-08Suggest `if let`/`let_else` for refutable pat in `let`Esteban Kuber-14/+38
2022-03-08Change wording of suggestion to add missing `match` armEsteban Kuber-146/+146
2022-03-08Point at uncovered variants in enum definition in `note` instead of a ↵Esteban Kuber-523/+654
`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