about summary refs log tree commit diff
path: root/src/test/ui/span/issue-34264.stderr
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-102/+0
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-2/+2
2022-08-12Point out a single arg if we have a single arg incompatibilityMichael Goulet-1/+1
2022-06-27Use typed indices in argument mismatch algorithmMichael Goulet-2/+2
2022-04-16Implementation for 65853Jack Huey-7/+19
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.
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-7/+7
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-11Modify structured suggestion outputEsteban Küber-7/+7
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2020-10-15ensure arguments are included in count mismatch spanAndy Russell-6/+12
2020-06-27Fix wording for anonymous parameter name helpJames Box-2/+2
2020-02-11On mismatched argument count point at argumentsEsteban Küber-4/+8
2020-02-02parser: address review comments re. `self`.Mazdak Farrokhzad-0/+8
2019-11-18Surround types with backticks in type errorsEsteban Küber-1/+1
2019-11-18Remove E0308 note when primary label has all infoEsteban Küber-4/+1
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-2/+2
2019-11-06Remove "here" from "expected one of X here"Esteban Küber-3/+3
2019-10-02syntax: improve parameter without type suggestionsDavid Wood-0/+6
This commit improves the suggestions provided when function parameters do not have types: - A new suggestion is added for arbitrary self types, which suggests adding `self: ` before the type. - Existing suggestions are now provided when a `<` is found where a `:` was expected (previously only `,` and `)` or trait items), this gives suggestions in the case where the unnamed parameter type is generic in a free function. - The suggestion that a type name be provided (e.g. `fn foo(HashMap<u32>)` -> `fn foo(HashMap: TypeName<u32>)`) will no longer occur when a `<` was found instead of `:`. - The ident will not be used for recovery when a `<` was found instead of `:`. Signed-off-by: David Wood <david@davidtw.co>
2019-08-25parser: gracefully handle `fn foo(A | B: type)`.Mazdak Farrokhzad-6/+6
2019-05-30Recover gracefully from argument with missing type or param nameEsteban Küber-0/+20
2019-04-18hide `--explain` hint if error has no extended infoAndy Russell-1/+1
2019-03-11Update testsVadim Petrochenkov-8/+8
2018-12-25Remove licensesMark Rousskov-6/+6
2018-03-14update testsGuillaume Gomez-2/+2
2018-02-26Update UI testsVadim Petrochenkov-8/+8
2018-02-25Update ui testsGuillaume Gomez-0/+2
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-2/+0
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2017-12-10Point at whole method call instead of argsEsteban Küber-6/+6
To avoid confusion in cases where the code is ```rust fn foo() {} / foo( | bar() | ^^^ current diagnostics point here for arg count mismatch | ); |_^ new diagnostic span points here ``` as this leads to confusion making people think that the diagnostic is talking about `bar`'s arg count, not `foo`'s. Point at `fn`s definition on arg mismatch, just like we do for closures.
2017-11-24Merge cfail and ui tests into ui testsOliver Schneider-12/+12
2017-07-02report the total number of errors on compilation failureAriel Ben-Yehuda-1/+1
Prior to this PR, when we aborted because a "critical pass" failed, we displayed the number of errors from that critical pass. While that's the number of errors that caused compilation to abort in *that place*, that's not what people really want to know. Instead, always report the total number of errors, and don't bother to track the number of errors from the last pass that failed. This changes the compiler driver API to handle errors more smoothly, and therefore is a compiler-api-[breaking-change]. Fixes #42793.
2017-07-02Revert "Change error count messages"Ariel Ben-Yehuda-1/+1
This reverts commit 5558c64f33446225739c1153b43d2e309bb4f50e.
2017-05-24Change error count messagesMichael Kohl-1/+1
See #33525 for details.
2017-04-07Merge branch 'master' into ty-placeholderEsteban Küber-3/+3
2017-04-02Introduce `TyErr` independent from `TyInfer`Esteban Küber-0/+49
Add a `TyErr` type to represent unknown types in places where parse errors have happened, while still able to build the AST. Initially only used to represent incorrectly written fn arguments and avoid "expected X parameters, found Y" errors when called with the appropriate amount of parameters. We cannot use `TyInfer` for this as `_` is not allowed as a valid argument type. Example output: ```rust error: expected one of `:` or `@`, found `,` --> file.rs:12:9 | 12 | fn bar(x, y: usize) {} | ^ error[E0061]: this function takes 2 parameters but 3 parameters were supplied --> file.rs:19:9 | 12 | fn bar(x, y) {} | --------------- defined here ... 19 | bar(1, 2, 3); | ^^^^^^^ expected 2 parameters ```