@@ -1908,20 +1908,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19081908 ct_op : |ct| ct. normalize ( self . tcx , ty:: ParamEnv :: empty ( ) ) ,
19091909 } ,
19101910 ) ;
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+ }
19251930 }
19261931
19271932 true
@@ -1932,7 +1937,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19321937 }
19331938
19341939 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 ( ) ) ;
19361942 if candidates. is_empty ( ) {
19371943 return false ;
19381944 }
0 commit comments