about summary refs log tree commit diff
path: root/src/test/ui/traits/bound
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1109/+0
2022-12-14Tweak output for bare `dyn Trait` in argumentsEsteban Küber-0/+4
Fix #35825.
2022-10-01bless ui testsMaybe Waffle-1/+1
2022-09-12A SubstitutionPart is not a deletion if it replaces nothing with nothingMichael Goulet-3/+2
2022-08-21Adjust messages, address some nitsMichael Goulet-4/+4
2022-08-21Point at struct field if possibleMichael Goulet-8/+8
2022-08-21Rework point-at-argMichael Goulet-5/+2
2022-08-18Reword "Required because of the requirements on the impl of ..."Andy Wang-2/+2
2022-07-11Do not mention private Self types from other cratesMichael Goulet-1/+0
2022-07-01Shorten def_span for more items.Camille GILLOT-2/+2
2022-06-16diagnostics: fix trailing spaceklensy-8/+8
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-04Dedup logic and improve output for other types that impl traitEsteban Kuber-2/+2
2022-04-04Fix #90970, doesn't address #87437Esteban Kuber-0/+35
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-3/+5
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-12-04Use multipart suggestions.Camille GILLOT-1/+6
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-6/+6
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-09-26Remove box syntax from most places in src/test outside of the issues direst31-6/+5
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-4/+12
2021-08-16Use note to point at bound introducing requirementEsteban Küber-59/+96
2021-08-12Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylevGuillaume Gomez-1/+1
Link to edition guide instead of issues for 2021 lints. This changes the 2021 lints to not link to github issues, but to the edition guide instead. Fixes #86996
2021-08-11Modify structured suggestion outputEsteban Küber-19/+26
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-09Link to edition guide instead of issues for 2021 lints.Mara Bos-1/+1
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-7/+7
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-4/+11
* 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-06-25Address PR feedbackRyan Levick-2/+2
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-2/+2
2021-05-04Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakisbors-2/+5
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
2021-04-19fix suggestion for unsized function parameterslcnr-2/+2
2021-04-16Fix testsRyan Levick-2/+5
2021-02-09Organize trait test filesBram van den Heuvel-0/+1000