about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2021-10-08 01:00:15 +0900
committerrhysd <lin90162@yahoo.co.jp>2021-10-09 00:07:37 +0900
commit7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2 (patch)
treea880d11cf342266656ebd93b3b948a7dddad74a7 /compiler
parentca8078d7b2e40c24a39e5fe2a910afef4c91ebfc (diff)
downloadrust-7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2.tar.gz
rust-7b9ddbdcf261c0010b24f53281bf2f27d02eb6f2.zip
Show detailed expected/found types in error message when trait paths are the same
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs14
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,
+                }
             }
         }
     }