@@ -379,40 +379,41 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
379
379
values : Option < ValuePairs < ' tcx > > ,
380
380
terr : & TypeError < ' tcx > )
381
381
{
382
- let expected_found = match values {
383
- None => None ,
384
- Some ( values) => match self . values_str ( & values) {
385
- Some ( ( expected, found) ) => Some ( ( expected, found) ) ,
386
- None => {
387
- // Derived error. Cancel the emitter.
388
- self . tcx . sess . diagnostic ( ) . cancel ( diag) ;
389
- return
390
- }
382
+ let ( expected_found, is_simple_error) = match values {
383
+ None => ( None , false ) ,
384
+ Some ( values) => {
385
+ let is_simple_error = match values {
386
+ ValuePairs :: Types ( exp_found) => {
387
+ exp_found. expected . is_primitive ( ) && exp_found. found . is_primitive ( )
388
+ }
389
+ _ => false ,
390
+ } ;
391
+ let vals = match self . values_str ( & values) {
392
+ Some ( ( expected, found) ) => Some ( ( expected, found) ) ,
393
+ None => {
394
+ // Derived error. Cancel the emitter.
395
+ self . tcx . sess . diagnostic ( ) . cancel ( diag) ;
396
+ return
397
+ }
398
+ } ;
399
+ ( vals, is_simple_error)
391
400
}
392
401
} ;
393
402
394
403
let span = cause. span ;
395
404
396
405
if let Some ( ( expected, found) ) = expected_found {
397
- let is_simple_error = if let & TypeError :: Sorts ( ref values) = terr {
398
- values. expected . is_primitive ( ) && values. found . is_primitive ( )
399
- } else {
400
- false
401
- } ;
402
-
403
- if !is_simple_error {
404
- if expected == found {
405
- if let & TypeError :: Sorts ( ref values) = terr {
406
- diag. note_expected_found_extra (
407
- & "type" , & expected, & found,
408
- & format ! ( " ({})" , values. expected. sort_string( self . tcx) ) ,
409
- & format ! ( " ({})" , values. found. sort_string( self . tcx) ) ) ;
410
- } else {
411
- diag. note_expected_found ( & "type" , & expected, & found) ;
412
- }
413
- } else {
406
+ match ( terr, is_simple_error, expected == found) {
407
+ ( & TypeError :: Sorts ( ref values) , false , true ) => {
408
+ diag. note_expected_found_extra (
409
+ & "type" , & expected, & found,
410
+ & format ! ( " ({})" , values. expected. sort_string( self . tcx) ) ,
411
+ & format ! ( " ({})" , values. found. sort_string( self . tcx) ) ) ;
412
+ }
413
+ ( _, false , _) => {
414
414
diag. note_expected_found ( & "type" , & expected, & found) ;
415
415
}
416
+ _ => ( ) ,
416
417
}
417
418
}
418
419
0 commit comments