rust/compiler
bors 68dfa07e3b 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.
2021-10-10 15:59:28 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast remove unwrap_or! macro 2021-10-08 19:32:16 +03:00
rustc_ast_lowering Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obk 2021-10-09 11:56:00 +02:00
rustc_ast_passes Allow adding a set of cfg's to hide from being implicitly doc(cfg)'d 2021-10-05 18:04:15 +02:00
rustc_ast_pretty
rustc_attr Move some HashStable impls. 2021-10-03 16:08:50 +02:00
rustc_borrowck Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514 2021-10-08 22:30:40 +02:00
rustc_builtin_macros Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514 2021-10-08 22:30:40 +02:00
rustc_codegen_cranelift Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa 2021-10-08 09:04:06 +00:00
rustc_codegen_gcc Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
rustc_codegen_llvm Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa 2021-10-10 08:16:22 +00:00
rustc_codegen_ssa Rollup merge of #89634 - hawkw:eliza/enable-err-warn, r=oli-obk 2021-10-09 11:55:59 +02:00
rustc_const_eval Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa 2021-10-08 09:04:06 +00:00
rustc_data_structures Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett 2021-10-04 21:12:33 -07:00
rustc_driver Update compiler/rustc_driver/src/lib.rs 2021-10-07 09:52:51 -07:00
rustc_error_codes Consistently use 'supertrait'. 2021-10-02 08:05:44 +07:00
rustc_errors use structured fields in some existing warnings 2021-10-07 10:48:48 -07:00
rustc_expand Improve help for recursion limit errors 2021-09-28 22:17:13 +02:00
rustc_feature Rollup merge of #89605 - camelid:fix-version, r=nagisa 2021-10-09 11:55:58 +02:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obk 2021-10-09 11:56:00 +02:00
rustc_hir_pretty Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
rustc_incremental Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
rustc_index Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett 2021-10-04 13:58:17 -07:00
rustc_infer Auto merge of #89633 - rhysd:issue-65230, r=petrochenkov 2021-10-10 15:59:28 +00:00
rustc_interface Enable AutoFDO. 2021-10-06 19:36:52 +00:00
rustc_lexer
rustc_lint Rollup merge of #89672 - klensy:unwrap-or-macro, r=jackh726 2021-10-08 22:30:43 +02:00
rustc_lint_defs Rollup merge of #89461 - crlf0710:dyn_upcasting_lint, r=nikomatsakis 2021-10-07 16:24:49 +02:00
rustc_llvm Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoerister 2021-10-07 20:26:11 -07:00
rustc_macros Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister 2021-10-05 09:45:11 +00:00
rustc_metadata Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514 2021-10-08 22:30:40 +02:00
rustc_middle Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa 2021-10-10 08:16:22 +00:00
rustc_mir_build clippy::complexity fixes 2021-10-08 20:07:44 +02:00
rustc_mir_dataflow comma-related changes 2021-10-07 11:29:47 -07:00
rustc_mir_transform clippy::complexity fixes 2021-10-08 20:07:44 +02:00
rustc_monomorphize Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
rustc_parse some clippy::perf fixes 2021-10-07 22:31:33 +02:00
rustc_parse_format
rustc_passes Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obk 2021-10-09 11:56:00 +02:00
rustc_plugin_impl Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
rustc_privacy Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot 2021-10-02 10:52:09 +00:00
rustc_query_impl Auto merge of #89343 - Mark-Simulacrum:no-args-queries, r=cjgillot 2021-10-09 13:13:07 +00:00
rustc_query_system Query the fingerprint style during key reconstruction 2021-10-06 22:19:48 -04:00
rustc_resolve remove unwrap_or! macro 2021-10-08 19:32:16 +03:00
rustc_save_analysis Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister 2021-10-05 09:45:11 +00:00
rustc_serialize
rustc_session Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkov 2021-10-07 20:26:14 -07:00
rustc_span Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank 2021-10-07 20:26:15 -07:00
rustc_symbol_mangling Remove re-export. 2021-10-03 16:08:54 +02:00
rustc_target add platform support details file for armv7-unknown-linux-uclibc 2021-10-06 14:33:13 +00:00
rustc_trait_selection Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514 2021-10-08 22:30:40 +02:00
rustc_traits clippy::complexity fixes 2021-10-08 20:07:44 +02:00
rustc_ty_utils Remove various unused feature gates 2021-10-02 19:09:18 +02:00
rustc_type_ir Add two inline annotations for hot functions 2021-10-03 12:43:43 -04:00
rustc_typeck Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514 2021-10-08 22:30:40 +02:00