about summary refs log tree commit diff
path: root/src/test/ui/did_you_mean
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-3685/+0
2023-01-01Verbose suggestionsEsteban Küber-10/+25
2022-12-28Use verbose suggestions for mutability errorsEsteban Küber-28/+60
2022-12-05Tweak "the following other types implement trait"Esteban Küber-9/+0
When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types. fix fmt
2022-11-08use subdiagnostic for sugesting add letyukang-0/+5
2022-11-05Do not make typo suggestions when suggesting pattern matchingDeadbeef-0/+30
Fixes #103909.
2022-10-05Delay function resolution error until typeckMichael Goulet-8/+8
2022-10-01bless ui testsMaybe Waffle-2/+2
2022-09-22Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, ↵bors-2/+2
r=oli-obk Require `#[const_trait]` on `Trait` for `impl const Trait` r? `@oli-obk`
2022-09-16bless testsDeadbeef-2/+2
2022-09-15more tweak on diagnostic messagesyukang-21/+53
2022-09-15fix 101793, fix the wording of help msg for bitwise notyukang-6/+16
2022-08-21Prefer non-Self non-method types over Self, firstMichael Goulet-8/+8
2022-08-21Rework point-at-argMichael Goulet-4/+8
2022-08-05recover require,include instead of use in itemyukang-2/+30
2022-07-31--bless testsMaybe Waffle-5/+15
2022-07-07Track implicit `Sized` obligations in type paramsEsteban Küber-1/+1
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-01Shorten def_span for more items.Camille GILLOT-2/+2
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-1/+1
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-1/+1
use `def_ident_span` , `body_owner_def_id` instead of `in_progress_typeck_results`, `guess_head_span` use `body_id.owner` directly add description to label
2022-06-16diagnostics: fix trailing spaceklensy-2/+2
2022-06-13Improve parsing errors and suggestions for bad if statementsMichael Goulet-2/+8
2022-06-07recover `import` instead of `use` in itemMichael Goulet-0/+44
2022-04-24Fix suggestion for `_` on return type for fn in impl for TraitMichael Goulet-11/+16
2022-04-24Suggest replacing `_` in type signature of impl for TraitMichael Goulet-0/+43
2022-04-16Implementation for 65853Jack Huey-1/+8
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-04Refer to the TraitRef::identity in the message to be clearerEsteban Kuber-6/+6
2022-04-04Dedup logic and improve output for other types that impl traitEsteban Kuber-10/+10
2022-04-04Fix list lengthEsteban Kuber-0/+18
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-4/+6
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-04-01Rollup merge of #95293 - compiler-errors:braces, r=davidtwcoMatthias Krüger-15/+63
suggest wrapping single-expr blocks in square brackets Suggests a fix in cases like: ```diff - const A: [i32; 1] = { 1 }; + const A: [i32; 1] = [ 1 ]; ^ ^ ``` Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`). Fixes #95289
2022-03-27suggest wrapping in struct tuples as wellMichael Goulet-3/+25
2022-03-27do not suggest enum tuple variant for named field variantMichael Goulet-1/+24
2022-03-27suggest wrapping patterns with compatible enum variantsMichael Goulet-0/+109
2022-03-24suggest wrapping single-expr blocks in square bracketsMichael Goulet-15/+63
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-2/+3
2022-03-02Add more tests for mismatched Option/Result return types.Mara Bos-8/+68
2022-02-28Tweak diagnosticsEsteban Kuber-36/+15
* Recover from invalid `'label: ` before block. * Make suggestion to enclose statements in a block multipart. * Point at `match`, `while`, `loop` and `unsafe` keywords when failing to parse their expression. * Do not suggest `{ ; }`. * Do not suggest `|` when very unlikely to be what was wanted (in `let` statements).
2022-02-14Make `find_similar_impl_candidates` a little fuzzier.Ben Reeves-1/+2
2022-01-22respect doc(hidden) when suggesting available fieldsIbraheem Ahmed-0/+43
2022-01-18generic_arg_infer: placeholder in signature errlcnr-20/+20
2022-01-17Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, ↵Matthias Krüger-7/+7
r=nagisa Fix suggesting turbofish with lifetime arguments Now we suggest turbofish correctly given exprs like `foo<'_>`. Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-14Don't use source-map when detecting struct field shorthandMichael Goulet-1/+1
2022-01-14Fix `try wrapping expression in variant` suggestion with struct field shorthandMichael Goulet-9/+30
2022-01-13Fix suggesting turbofish with lifetime argumentsMichael Goulet-7/+7
2021-12-18Auto merge of #92062 - matthiaskrgr:rollup-en3p4sb, r=matthiaskrgrbors-9/+29
Rollup of 7 pull requests Successful merges: - #91439 (Mark defaulted `PartialEq`/`PartialOrd` methods as const) - #91516 (Improve suggestion to change struct field to &mut) - #91896 (Remove `in_band_lifetimes` for `rustc_passes`) - #91909 (:arrow_up: rust-analyzer) - #91922 (Remove `in_band_lifetimes` from `rustc_mir_dataflow`) - #92025 (Revert "socket ancillary data implementation for dragonflybsd.") - #92030 (Update stdlib to the 2021 edition) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-18get_mut_span_in_struct_field uses span.betweenLucas Kent-1/+1
2021-12-17Improve suggestion to change struct field to &mutLucas Kent-9/+29
2021-12-04Use multipart suggestions.Camille GILLOT-1/+5
2021-12-04Include output type in fn trait bounds.Camille GILLOT-1/+1