@@ -562,40 +562,41 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
562
562
values : Option < ValuePairs < ' tcx > > ,
563
563
terr : & TypeError < ' tcx > )
564
564
{
565
- let expected_found = match values {
566
- None => None ,
567
- Some ( values) => match self . values_str ( & values) {
568
- Some ( ( expected, found) ) => Some ( ( expected, found) ) ,
569
- None => {
570
- // Derived error. Cancel the emitter.
571
- self . tcx . sess . diagnostic ( ) . cancel ( diag) ;
572
- return
573
- }
565
+ let ( expected_found, is_simple_error) = match values {
566
+ None => ( None , false ) ,
567
+ Some ( values) => {
568
+ let is_simple_error = match values {
569
+ ValuePairs :: Types ( exp_found) => {
570
+ exp_found. expected . is_primitive ( ) && exp_found. found . is_primitive ( )
571
+ }
572
+ _ => false ,
573
+ } ;
574
+ let vals = match self . values_str ( & values) {
575
+ Some ( ( expected, found) ) => Some ( ( expected, found) ) ,
576
+ None => {
577
+ // Derived error. Cancel the emitter.
578
+ self . tcx . sess . diagnostic ( ) . cancel ( diag) ;
579
+ return
580
+ }
581
+ } ;
582
+ ( vals, is_simple_error)
574
583
}
575
584
} ;
576
585
577
586
let span = cause. span ;
578
587
579
588
if let Some ( ( expected, found) ) = expected_found {
580
- let is_simple_error = if let & TypeError :: Sorts ( ref values) = terr {
581
- values. expected . is_primitive ( ) && values. found . is_primitive ( )
582
- } else {
583
- false
584
- } ;
585
-
586
- if !is_simple_error {
587
- if expected == found {
588
- if let & TypeError :: Sorts ( ref values) = terr {
589
- diag. note_expected_found_extra (
590
- & "type" , & expected, & found,
591
- & format ! ( " ({})" , values. expected. sort_string( self . tcx) ) ,
592
- & format ! ( " ({})" , values. found. sort_string( self . tcx) ) ) ;
593
- } else {
594
- diag. note_expected_found ( & "type" , & expected, & found) ;
595
- }
596
- } else {
589
+ match ( terr, is_simple_error, expected == found) {
590
+ ( & TypeError :: Sorts ( ref values) , false , true ) => {
591
+ diag. note_expected_found_extra (
592
+ & "type" , & expected, & found,
593
+ & format ! ( " ({})" , values. expected. sort_string( self . tcx) ) ,
594
+ & format ! ( " ({})" , values. found. sort_string( self . tcx) ) ) ;
595
+ }
596
+ ( _, false , _) => {
597
597
diag. note_expected_found ( & "type" , & expected, & found) ;
598
598
}
599
+ _ => ( ) ,
599
600
}
600
601
}
601
602
0 commit comments