about summary refs log tree commit diff
path: root/src/test/ui/ufcs
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-589/+0
2023-01-09Auto merge of #101947 - aliemjay:astconv-normalize, r=lcnrbors-1/+1
Don't normalize in AstConv See individual commits. Fixes #101350 Fixes #54940
2023-01-07don't normalize in astconvAli MJ Al-Nasrawy-1/+1
We delay projection normalization to further stages in order to register user type annotations before normalization in HIR typeck. There are two consumers of astconv: ItemCtxt and FnCtxt. The former already expects unnormalized types from astconv, see its AstConv trait impl. The latter needs `RawTy` for a cleaner interface. Unfortunately astconv still needs the normalization machinery in order to resolve enum variants that have projections in the self type, e.g. `<<T as Trait>::Assoc>::StructVariant {}`. This is why `AstConv::normalize_ty_2` is necessary.
2023-01-06use smaller spans for missing lifetime/generic argsTakayuki Maeda-2/+2
fix rustdoc ui test
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-6/+0
available
2022-12-05Tweak "the following other types implement trait"Esteban Küber-16/+6
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-08-27Revert "Remove deferred sized checks"Michael Goulet-3/+22
This reverts commit 33212bf7f527798a8cfa2bbb38781742f4ca718a.
2022-08-21Prefer non-Self non-method types over Self, firstMichael Goulet-2/+2
2022-08-21Rework point-at-argMichael Goulet-2/+4
2022-04-16Implementation for 65853Jack Huey-2/+16
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-1/+1
2022-04-04Dedup logic and improve output for other types that impl traitEsteban Kuber-5/+5
2022-04-04Fix list lengthEsteban Kuber-0/+4
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-0/+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 `?`.
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-5/+0
2021-10-13Remove textual span from diagnostic stringOli Scherer-8/+8
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-6/+6
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-2/+2
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-4/+4
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-1/+5
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-05-11improve diagnosts for GATsb-naber-14/+14
2021-02-22Update test cases0yoyoyo-12/+12
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-5/+49
2020-10-06Fix tests from rebaseMatthew Jasper-0/+1
2020-09-02pretty: trim paths of unique symbolsDan Aloni-1/+1
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-08-22Use smaller def span for functionsAaron Hill-4/+4
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-03-21Bless testsLeSeulArtichaut-2/+2
2020-03-12update testsMark Mansi-8/+8
2020-02-21Implement RFC 2532 – Associated Type DefaultsJonas Schievink-7/+7
2020-01-08Unify output of "variant not found" errorsEsteban Küber-4/+4
2019-11-18Surround types with backticks in type errorsEsteban Küber-2/+2
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-12/+12
2019-10-27Point at local similarly named element and tweak references to variantsEsteban Küber-0/+21
Point at the span for the definition of ADTs internal to the current crate. Look at the leading char of the ident to determine whether we're expecting a likely fn or any of a fn, a tuple struct or a tuple variant. Turn fn `add_typo_suggestion` into a `Resolver` method.
2019-10-26Rollup merge of #65773 - estebank:sugg-whitespace, r=CentrilMazdak Farrokhzad-0/+2
Increase spacing for suggestions in diagnostics Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages. r? @Centril
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+2
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-23Update ui testsGuillaume Gomez-1/+1
2019-10-17Update ui testsGuillaume Gomez-1/+1
2019-10-11Print lifetimes with backticksYuki Okushi-4/+4
2019-09-02Refer to "`self` type" instead of "receiver type"Esteban Küber-18/+19
2019-07-16Update the help message on error for self typeLimira-3/+3
2019-04-29Suggest try_into when possibleEsteban Küber-0/+8
2019-04-18hide `--explain` hint if error has no extended infoAndy Russell-4/+3
2019-04-10clarify what the item is in "not a module" errorAndy Russell-6/+6
2019-03-23Tweak spans for E0599Esteban Küber-6/+2
2019-03-11Update testsVadim Petrochenkov-36/+36
2019-01-09clarify resolve typo suggestionAndy Russell-7/+7
Include the kind of the binding that we're suggesting, and use a structured suggestion.
2018-12-26Fixed more tests.Alexander Regueiro-4/+8
2018-12-25Remove licensesMark Rousskov-99/+59
2018-12-20Refactor and add comments to code in receiver_is_validMichael Hewson-9/+9
also updated some error messages removed the code manually checking for `receiver_ty: Deref<Target=self_ty>`, in favour of using autoderef but only doing one iteration. This will cause error messages to be more consistent. Before, a "mismatched method receiver" error would be emitted when `receiver_ty` was valid except for a lifetime parameter, but only when `feature(arbitrary_self_types)` was enabled, and without the feature flag the error would be "uncoercible receiver". Now it emits "mismatched method receiver" in both cases.
2018-11-18resolve: Avoid sentence breaks in diagnosticsVadim Petrochenkov-8/+8