about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-10 15:59:28 +0000
committerbors <bors@rust-lang.org>2021-10-10 15:59:28 +0000
commit68dfa07e3bbbfe9100a9b1047c274717bdf452a1 (patch)
treedcbae8f386e9c59bab4a2c18d183f2bc687fad24 /compiler/rustc_codegen_llvm/src
parent0c87288f92b7e6365d61cfbcbc453ea4c696c030 (diff)
parent9211beef087b1c87bb0335cac0c3b0676af7f54a (diff)
downloadrust-68dfa07e3bbbfe9100a9b1047c274717bdf452a1.tar.gz
rust-68dfa07e3bbbfe9100a9b1047c274717bdf452a1.zip
Auto merge of #89633 - rhysd:issue-65230, r=petrochenkov
Show detailed expected/found types in error message when trait paths are the same

Fixes #65230.

### Issue solved by this PR

```rust
trait T {
    type U;
    fn f(&self) -> Self::U;
}

struct X<'a>(&'a mut i32);

impl<'a> T for X<'a> {
    type U = &'a i32;
    fn f(&self) -> Self::U {
        self.0
    }
}

fn main() {}
```

Compiler generates the following note:

```
note: ...so that the types are compatible
  --> test.rs:10:28
   |
10 |       fn f(&self) -> Self::U {
   |  ____________________________^
11 | |         self.0
12 | |     }
   | |_____^
   = note: expected `T`
              found `T`
```

This note is not useful since the expected type and the found type are the same.

### How this PR solve the issue

When the expected type and the found type are exactly the same in string representation, the note falls back to the detailed string representation of trait ref:

```
note: ...so that the types are compatible
  --> test.rs:10:28
   |
10 |       fn f(&self) -> Self::U {
   |  ____________________________^
11 | |         self.0
12 | |     }
   | |_____^
   = note: expected `<X<'a> as T>`
              found `<X<'_> as T>`
```

So that a user can notice what was different between the expected one and the found one.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions