| Age | Commit message (Collapse) | Author | Lines |
|
Tweak binop errors
* Suggest potentially missing binop trait bound (fix #73416)
* Use structured suggestion for dereference in binop
|
|
Verify that the binop trait *is* implemented for the types *if* all the
involved type parameters are replaced with fresh inferred types. When
this is the case, it means that the type parameter was indeed missing a
trait bound. If this is not the case, provide a generic `note` refering
to the type that doesn't implement the expected trait.
|
|
* Suggest potentially missing binop trait bound (fix #73416)
* Use structured suggestion for dereference in binop
|
|
Try to suggest dereferences on trait selection failed
Fixes #39029 Fixes #62530
This PR consists of two parts:
1. Decouple `Autoderef` with `FnCtxt` and move `Autoderef` to `librustc_trait_selection`.
2. Try to suggest dereferences when trait selection failed.
The first is needed because:
1. For suggesting dereferences, the struct `Autoderef` should be used. But before this PR, it is placed in `librustc_typeck`, which depends on `librustc_trait_selection`. But trait selection error emitting happens in `librustc_trait_selection`, if we want to use `Autoderef` in it, dependency loop is inevitable. So I moved the `Autoderef` to `librustc_trait_selection`.
2. Before this PR, `FnCtxt` is coupled to `Autoderef`, and `FnCtxt` only exists in `librustc_typeck`. So decoupling is needed.
After this PR, we can get suggestion like this:
```
error[E0277]: the trait bound `&Baz: Happy` is not satisfied
--> $DIR/trait-suggest-deferences-multiple.rs:34:9
|
LL | fn foo<T>(_: T) where T: Happy {}
| ----- required by this bound in `foo`
...
LL | foo(&baz);
| ^^^^
| |
| the trait `Happy` is not implemented for `&Baz`
| help: consider adding dereference here: `&***baz`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
```
r? @estebank
|
|
|
|
|
|
Unify region variables when projecting associated types
This is required to avoid cycles when evaluating auto trait predicates.
Notably, this is required to be able add Chalk types to `CtxtInterners` for `cfg(parallel_compiler)`.
r? @nikomatsakis
|
|
Specialization is unsound
As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound.
I also expanded the "incomplete feature" warning to link the user to the tracking issue.
|
|
This is required to avoid cycles when evaluating auto trait
predicates.
|
|
|
|
Previously, we would suggest `Box<Self>` as a valid receiver, even if
method resolution only succeeded due to an autoderef (e.g. to `&self`)
|
|
r=estebank
Fix trait alias inherent impl resolution
Fixes #60021 and fixes #72415.
Obviously, the fix was very easy, but getting started with the testing and debugging rust compiler was an interesting experience. Now I can cross it off my bucket list!
|
|
|
|
|
|
|
|
|
|
Detect type parameter that might require lifetime constraint.
Do not name `ReVar`s in expected/found output.
Reword text suggesting to check the lifetimes.
|
|
|
|
|
|
Fixes #60021 and #72415.
|
|
Fix suggestion to borrow in struct
The corresponding issue is #71136.
The compiler suggests that borrowing `the_foos` might solve the problem. This is obviously incorrect.
```
struct Foo(u8);
#[derive(Clone)]
struct FooHolster {
the_foos: Vec<Foo>,
}
```
I propose as fix to check if there is any colon in the span. However, there might a case where `my_method(B { a: 1, b : foo })` would be appropriate to show a suggestion for `&B ...`. To fix that too, we can simply check if there is a bracket in the span. This is only possible because both spans are different.
Issue's span: `the_foos: Vec<Foo>`
other's span: `B { a : 1, b : foo }`
|
|
|
|
|
|
Tweak `'static` suggestion code
Fix #71196.
|
|
|
|
|
|
|
|
|
|
|
|
When evaluating the derived obligations from super traits, maintain a
reference to the original obligation in order to give more actionable
context in the output.
|
|
Rename fn_has_self_argument to fn_has_self_parameter
Rename AssocItemKind::Method to AssocItemKind::Fn
Refine has_no_input_arg
Refine has_no_input_arg
Revert has_no_input_arg
Refine suggestion_descr
Move as_def_kind into AssocKind
Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
Fix tidy check issue
Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
|
|
|
|
|
|
Keep more information about trait binding failures.
|
|
|
|
Add test for #59023
Adds a test for https://github.com/rust-lang/rust/issues/59023
Closes https://github.com/rust-lang/rust/issues/59023
|
|
|
|
|
|
Some of the bound restriction structured suggestions were incorrect
while others had subpar output.
|
|
|
|
|
|
|
|
|
|
|
|
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.
This also adds docs in the unstable book for the current state of auto traits.
|
|
|
|
|
|
Increase verbosity when suggesting subtle code changes
Do not suggest changes that are actually quite small inline, to minimize the likelihood of confusion.
Fix #69243.
|
|
Only display definition when suggesting a typo
Closes #70206
r? @Centril
|
|
|