@@ -1908,20 +1908,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1908
1908
ct_op : |ct| ct. normalize ( self . tcx , ty:: ParamEnv :: empty ( ) ) ,
1909
1909
} ,
1910
1910
) ;
1911
- err. highlighted_help ( vec ! [
1912
- StringPart :: normal( format!( "the trait `{}` " , cand. print_trait_sugared( ) ) ) ,
1913
- StringPart :: highlighted( "is" ) ,
1914
- StringPart :: normal( " implemented for `" ) ,
1915
- StringPart :: highlighted( cand. self_ty( ) . to_string( ) ) ,
1916
- StringPart :: normal( "`" ) ,
1917
- ] ) ;
1918
-
1919
- if let [ TypeError :: Sorts ( exp_found) ] = & terrs[ ..] {
1920
- let exp_found = self . resolve_vars_if_possible ( * exp_found) ;
1921
- err. help ( format ! (
1922
- "for that trait implementation, expected `{}`, found `{}`" ,
1923
- exp_found. expected, exp_found. found
1924
- ) ) ;
1911
+ if !cand. references_error ( ) {
1912
+ err. highlighted_help ( vec ! [
1913
+ StringPart :: normal( format!(
1914
+ "the trait `{}` " ,
1915
+ cand. print_trait_sugared( )
1916
+ ) ) ,
1917
+ StringPart :: highlighted( "is" ) ,
1918
+ StringPart :: normal( " implemented for `" ) ,
1919
+ StringPart :: highlighted( cand. self_ty( ) . to_string( ) ) ,
1920
+ StringPart :: normal( "`" ) ,
1921
+ ] ) ;
1922
+
1923
+ if let [ TypeError :: Sorts ( exp_found) ] = & terrs[ ..] {
1924
+ let exp_found = self . resolve_vars_if_possible ( * exp_found) ;
1925
+ err. help ( format ! (
1926
+ "for that trait implementation, expected `{}`, found `{}`" ,
1927
+ exp_found. expected, exp_found. found
1928
+ ) ) ;
1929
+ }
1925
1930
}
1926
1931
1927
1932
true
@@ -1932,7 +1937,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1932
1937
}
1933
1938
1934
1939
let other = if other { "other " } else { "" } ;
1935
- let report = |candidates : Vec < TraitRef < ' tcx > > , err : & mut Diag < ' _ > | {
1940
+ let report = |mut candidates : Vec < TraitRef < ' tcx > > , err : & mut Diag < ' _ > | {
1941
+ candidates. retain ( |tr| !tr. references_error ( ) ) ;
1936
1942
if candidates. is_empty ( ) {
1937
1943
return false ;
1938
1944
}
0 commit comments