diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-20 14:44:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-20 14:44:50 -0700 |
| commit | a1404a93f9632d768d7268934e6380a9b9614834 (patch) | |
| tree | 9532ddbaad645d10a3af580206546e96ce0f14bc /src/test/debuginfo/enum-thinlto.rs | |
| parent | 033013cab3a861224fd55f494c8be1cb0349eb49 (diff) | |
| parent | f1e07103d3ebac4e820311254e077481d00bed49 (diff) | |
| download | rust-a1404a93f9632d768d7268934e6380a9b9614834.tar.gz rust-a1404a93f9632d768d7268934e6380a9b9614834.zip | |
Rollup merge of #72456 - ldm0:dereftrait, r=estebank
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
Diffstat (limited to 'src/test/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions
