about summary refs log tree commit diff
path: root/src/test/ui/fn
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1025/+0
2023-01-05Tweak wording of fn call with wrong number of argsEsteban Küber-2/+2
2023-01-04Restore Fn trait noteMichael Goulet-2/+14
2023-01-03Suggest more impl Trait on `-> _`Michael Goulet-7/+111
2022-12-23Move testsCaio-0/+52
2022-12-02Don't elide information when printing E0308 with ZverboseMichael Goulet-0/+34
2022-08-28More descriptive argument placeholdersMichael Goulet-4/+4
2022-08-28Suggest calling when operator types mismatchMichael Goulet-7/+3
2022-08-27Suggest calling trait objects and parameters too, when possibleMichael Goulet-0/+8
2022-08-12Point out a single arg if we have a single arg incompatibilityMichael Goulet-5/+5
2022-08-09don't normalize wf predicateslcnr-32/+113
this allows us to soundly use unnormalized projections for wf
2022-07-15provide `generic_param_scope` for region errorslcnr-3/+5
2022-07-07Fix borrowck closure span.Camille GILLOT-2/+4
2022-06-03Fully stabilize NLLJack Huey-20/+2
2022-05-22Use revisions for NLL in various directoriesJack Huey-3/+9
2022-05-06Resolve vars in note_type_errJack Huey-14/+12
2022-05-02Fix invalid keyword order for function declarationsKen Matsui-0/+22
2022-04-16Implementation for 65853Jack Huey-17/+52
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-01-21Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obkMatthias Krüger-1/+1
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-18generic_arg_infer: placeholder in signature errlcnr-4/+4
2021-12-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-1/+1
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-14Add another regression test for unnormalized fn args with SelfJack Huey-0/+37
2021-12-08Rollup merge of #91531 - notriddle:notriddle/issue-87647-expected-semicolon, ↵Matthias Krüger-3/+3
r=estebank Do not add `;` to expected tokens list when it's wrong There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff). Fixes #87647
2021-12-04Do not add `;` to expected tokens list when it's wrongMichael Howell-3/+3
There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff). Fixes #87647
2021-12-03Tweak "call this function" suggestion to have smaller spanEsteban Kuber-2/+2
2021-12-02Change to check-passJack Huey-1/+1
2021-12-02Add additional test from rust issue number 91068Frank Steffahn-0/+22
2021-11-30Rollup merge of #91243 - jackh726:issue-91068, r=nikomatsakisYuki Okushi-0/+49
Don't treat unnormalized function arguments as well-formed Partial revert of #88312 r? ``@pnkfelix`` cc ``@nikomatsakis``
2021-11-29Bless nllJack Huey-0/+14
2021-11-25Don't treat unnormalized function arguments as well-formedjackh726-0/+35
2021-11-18Move some tests to more reasonable directoriesCaio-0/+12
2021-11-14Move some tests to more reasonable directoriesCaio-0/+104
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-12/+12
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-1/+3
2021-08-16Use note to point at bound introducing requirementEsteban Küber-3/+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-22Updated tests to reflect specified types in E0121Deadbeef-4/+4
2021-04-17Move some tests to more reasonable directories - 6Caio-0/+13
2020-12-22Add regression test for #80179ThePuzzlemaker-0/+48
2020-12-03Gracefully handle confusing -> with : in function return typemibac138-50/+86
2020-12-01Gracefully handle mistyping -> as => in function return typemibac138-0/+68
2020-10-27This flag is not really needed in the testSantiago Pastorino-1/+0
2020-10-27Add unsized_fn_params featureSantiago Pastorino-1/+1
2020-09-02pretty: trim paths of unique symbolsDan Aloni-24/+24
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-06-23review comments: wording and styleEsteban Küber-20/+20
2020-06-22Provide context on E0308 involving fn itemsEsteban Küber-10/+55
2020-05-08Skip tests on emscriptenYuki Okushi-0/+1
2020-05-06Move tests from `test/run-fail` to UIYuki Okushi-0/+10
2020-04-18Make Box<dyn FnOnce> respect self alignmentSantiago Pastorino-0/+24
2020-04-08Small tweaks to required bound spanEsteban Küber-1/+1