diff options
| author | rhysd <lin90162@yahoo.co.jp> | 2021-10-08 01:00:15 +0900 |
|---|---|---|
| committer | rhysd <lin90162@yahoo.co.jp> | 2021-10-09 00:07:37 +0900 |
| commit | 7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2 (patch) | |
| tree | a880d11cf342266656ebd93b3b948a7dddad74a7 /compiler/rustc_infer/src | |
| parent | ca8078d7b2e40c24a39e5fe2a910afef4c91ebfc (diff) | |
| download | rust-7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2.tar.gz rust-7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2.zip | |
Show detailed expected/found types in error message when trait paths are the same
Diffstat (limited to 'compiler/rustc_infer/src')
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index c44d4361f03..056709cd314 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2060,14 +2060,24 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { expected: exp_found.expected.print_only_trait_path(), found: exp_found.found.print_only_trait_path(), }; - self.expected_found_str(pretty_exp_found) + match self.expected_found_str(pretty_exp_found) { + Some((expected, found)) if expected == found => { + self.expected_found_str(exp_found) + } + ret => ret, + } } infer::PolyTraitRefs(exp_found) => { let pretty_exp_found = ty::error::ExpectedFound { expected: exp_found.expected.print_only_trait_path(), found: exp_found.found.print_only_trait_path(), }; - self.expected_found_str(pretty_exp_found) + match self.expected_found_str(pretty_exp_found) { + Some((expected, found)) if expected == found => { + self.expected_found_str(exp_found) + } + ret => ret, + } } } } |
