summary refs log tree commit diff
path: root/src/test/ui/inference
AgeCommit message (Collapse)AuthorLines
2022-10-23Rollup merge of #103305 - c410-f3r:moar-errors, r=petrochenkovDylan DPC-0/+22
Move some tests to more reasonable places r? `@petrochenkov`
2022-10-22Update UI testsclubby789-4/+45
2022-10-20Move some tests for more reasonable placesCaio-0/+22
2022-10-16fix `own_substs` ICETakayuki Maeda-0/+32
2022-10-05stop suggesting adding generic args for turbofishTakayuki Maeda-9/+20
2022-10-01bless ui testsMaybe Waffle-2/+2
2022-08-30Stabilize GATsJack Huey-3/+1
2022-08-21Rework ambiguity errorsMichael Goulet-27/+9
2022-08-21Account for relative pathsMichael Goulet-1/+1
2022-08-21Rework point-at-argMichael Goulet-12/+32
2022-07-20Normalize the arg spans to be within the call spanMichael Goulet-15/+12
2022-07-08Fix duplicated type annotation suggestionDaniel Xu-12/+0
Before, there was more or less duplicated suggestions to add type hints. Fix by clearing more generic suggestions when a more specific suggestion is possible. This fixes #93506 .
2022-07-04`InferSource::GenericArg`, check for containslcnr-9/+8
2022-07-04resolve vars in node substslcnr-1/+6
2022-07-04update infer cost computation for typeslcnr-0/+44
2022-07-01Show source of ambiguity in a few more placesMichael Goulet-6/+15
2022-06-28fix `emit_inference_failure_err` ICElcnr-0/+100
2022-06-23Rollup merge of #98269 - compiler-errors:provide-more-segment-res, ↵Michael Goulet-8/+8
r=petrochenkov Provide a `PathSegment.res` in more cases I find that in many cases, the `res` associated with a `PathSegment` is `Res::Err` even though the path was fully resolved. A few diagnostics use this `res` and their error messages suffer because of the lack of resolved segment. This fixes it a bit, but it's obviously not complete and I'm not exactly sure if it's correct.
2022-06-21Move some tests to more reasonable directoriesCaio-0/+299
2022-06-20Provide a segment res in more casesMichael Goulet-8/+8
2022-06-16diagnostics: fix trailing spaceklensy-2/+2
2022-06-11Rollup merge of #97703 - lcnr:post-89862, r=estebankDylan DPC-0/+154
some additional `need_type_info.rs` cleanup also fixes #97698, fixes #97806 cc `@estebank`
2022-06-08add test + don't warn on `Res::SelfTy`lcnr-0/+76
2022-06-08need_type_info: don't ICE when detected ty aliaslcnr-0/+78
fixes #97698
2022-06-06Deactivate feature gate explicit_generic_args_with_impl_traitNick Cameron-3/+3
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-06-02`generic_arg_contains_target`: ignore closureslcnr-8/+8
2022-06-02use verbose suggestionslcnr-3/+6
2022-06-02add new `emit_inference_failure_err`lcnr-72/+69
2022-05-20Rollup merge of #97109 - ↵Matthias Krüger-0/+52
TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk Fix misleading `cannot infer type for type parameter` error closes #93198
2022-05-20report ambiguous type parameters when their parents are impl or fnTakayuki Maeda-0/+20
fix ci error emit err for `impl_item`
2022-05-17fix misleading `cannot infer type for type parameter` errorTakayuki Maeda-0/+32
2022-05-13Add regression test for #28935Yuki Okushi-0/+9
2022-04-30Bless the UI testsScott McMurray-10/+4
2022-04-16Implementation for 65853Jack Huey-10/+66
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-03-03Cleanup feature gates.Camille GILLOT-3/+1
2022-02-08Rollup merge of #92715 - chordtoll:empty-string, r=davidtwcoMatthias Krüger-2/+11
Do not suggest char literal for zero-length strings PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided. The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint. This PR adds the missing check, and a test case to confirm the new behavior.
2022-01-16Only suggest char literal for single-character stringschordtoll-2/+11
2022-01-14Don't use source-map when detecting struct field shorthandMichael Goulet-1/+1
2022-01-04Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgrbors-60/+0
Rollup of 7 pull requests Successful merges: - #91587 (core::ops::unsize: improve docs for DispatchFromDyn) - #91907 (Allow `_` as the length of array types and repeat expressions) - #92515 (RustWrapper: adapt for an LLVM API change) - #92516 (Do not use deprecated -Zsymbol-mangling-version in bootstrap) - #92530 (Move `contains` method of Option and Result lower in docs) - #92546 (Update books) - #92551 (rename StackPopClean::None to Root) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-03Suggest changing quotes when str/char type mismatchchordtoll-0/+100
2021-12-23implement `generic_arg_infer` for array lengthslcnr-60/+0
2021-12-11Tweak assoc type obligation spansEsteban Kuber-1/+1
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-12-07Add test with multiple type params failing inferenceEsteban Kuber-12/+45
2021-12-07Refer to const params as "const params" and not "type params"Esteban Kuber-1/+1
2021-12-07Refer to uninferred `const` params by their name, instead of `{ _: _ }`Esteban Kuber-1/+1
When the value of a const param isn't inferred, replace it with the param name from the definition.
2021-12-07Only shown relevant type params in E0283 labelEsteban Kuber-1/+36
When we point at a binding to suggest giving it a type, erase all the type for ADTs that have been resolved, leaving only the ones that could not be inferred. For small shallow types this is not a problem, but for big nested types with lots of params, this can otherwise cause a lot of unnecessary visual output.
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-0/+9
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-19Auto merge of #91033 - JohnTitor:rollup-sr9zg6o, r=JohnTitorbors-0/+162
Rollup of 8 pull requests Successful merges: - #89258 (Make char conversion functions unstably const) - #90578 (add const generics test) - #90633 (Refactor single variant `Candidate` enum into a struct) - #90800 (bootstap: create .cargo/config only if not present) - #90942 (windows: Return the "Not Found" error when a path is empty) - #90947 (Move some tests to more reasonable directories - 9.5) - #90961 (Suggest removal of arguments for unit variant, not replacement) - #90990 (Arenas cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-19Auto merge of #90329 - nbdd0121:typeck, r=nagisabors-2/+75
Try all stable method candidates first before trying unstable ones Currently we try methods in this order in each step: * Stable by value * Unstable by value * Stable autoref * Unstable autoref * ... This PR changes it to first try pick methods without any unstable candidates, and if none is found, try again to pick unstable ones. Fix #90320 CC #88971, hopefully would allow us to rename the "unstable_*" methods for integer impls back. `@rustbot` label T-compiler T-libs-api
2021-11-18Move some tests to more reasonable directoriesCaio-0/+162