@@ -1582,18 +1582,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15821582 None => ( None , Mismatch :: Fixed ( "type" ) , false ) ,
15831583 Some ( values) => {
15841584 let ( is_simple_error, exp_found) = match values {
1585- ValuePairs :: Types ( exp_found) => {
1586- let is_simple_err =
1587- exp_found. expected . is_simple_text ( ) && exp_found. found . is_simple_text ( ) ;
1588- OpaqueTypesVisitor :: visit_expected_found (
1589- self . tcx ,
1590- exp_found. expected ,
1591- exp_found. found ,
1592- span,
1593- )
1594- . report ( diag) ;
1585+ ValuePairs :: Terms ( infer:: ExpectedFound {
1586+ expected : ty:: Term :: Ty ( expected) ,
1587+ found : ty:: Term :: Ty ( found) ,
1588+ } ) => {
1589+ let is_simple_err = expected. is_simple_text ( ) && found. is_simple_text ( ) ;
1590+ OpaqueTypesVisitor :: visit_expected_found ( self . tcx , expected, found, span)
1591+ . report ( diag) ;
15951592
1596- ( is_simple_err, Mismatch :: Variable ( exp_found) )
1593+ (
1594+ is_simple_err,
1595+ Mismatch :: Variable ( infer:: ExpectedFound { expected, found } ) ,
1596+ )
15971597 }
15981598 ValuePairs :: TraitRefs ( _) => ( false , Mismatch :: Fixed ( "trait" ) ) ,
15991599 _ => ( false , Mismatch :: Fixed ( "type" ) ) ,
@@ -1624,7 +1624,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
16241624 } ;
16251625 if let Some ( ( sp, msg) ) = secondary_span {
16261626 if swap_secondary_and_primary {
1627- let terr = if let Some ( infer:: ValuePairs :: Types ( infer:: ExpectedFound {
1627+ let terr = if let Some ( infer:: ValuePairs :: Terms ( infer:: ExpectedFound {
16281628 expected,
16291629 ..
16301630 } ) ) = values
@@ -2036,9 +2036,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20362036 }
20372037 FailureCode :: Error0308 ( failure_str) => {
20382038 let mut err = struct_span_err ! ( self . tcx. sess, span, E0308 , "{}" , failure_str) ;
2039- if let ValuePairs :: Types ( ty:: error:: ExpectedFound { expected, found } ) =
2040- trace. values
2041- {
2039+ if let Some ( ( expected, found) ) = trace. values . ty ( ) {
20422040 match ( expected. kind ( ) , found. kind ( ) ) {
20432041 ( ty:: Tuple ( _) , ty:: Tuple ( _) ) => { }
20442042 // If a tuple of length one was expected and the found expression has
@@ -2148,9 +2146,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
21482146 values : ValuePairs < ' tcx > ,
21492147 ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
21502148 match values {
2151- infer:: Types ( exp_found) => self . expected_found_str_ty ( exp_found) ,
21522149 infer:: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
2153- infer:: Consts ( exp_found) => self . expected_found_str ( exp_found) ,
2150+ infer:: Terms ( exp_found) => self . expected_found_str_term ( exp_found) ,
21542151 infer:: TraitRefs ( exp_found) => {
21552152 let pretty_exp_found = ty:: error:: ExpectedFound {
21562153 expected : exp_found. expected . print_only_trait_path ( ) ,
@@ -2178,16 +2175,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
21782175 }
21792176 }
21802177
2181- fn expected_found_str_ty (
2178+ fn expected_found_str_term (
21822179 & self ,
2183- exp_found : ty:: error:: ExpectedFound < Ty < ' tcx > > ,
2180+ exp_found : ty:: error:: ExpectedFound < ty :: Term < ' tcx > > ,
21842181 ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
21852182 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
21862183 if exp_found. references_error ( ) {
21872184 return None ;
21882185 }
21892186
2190- Some ( self . cmp ( exp_found. expected , exp_found. found ) )
2187+ Some ( match ( exp_found. expected , exp_found. found ) {
2188+ ( ty:: Term :: Ty ( expected) , ty:: Term :: Ty ( found) ) => self . cmp ( expected, found) ,
2189+ ( expected, found) => (
2190+ DiagnosticStyledString :: highlighted ( expected. to_string ( ) ) ,
2191+ DiagnosticStyledString :: highlighted ( found. to_string ( ) ) ,
2192+ ) ,
2193+ } )
21912194 }
21922195
21932196 /// Returns a string of the form "expected `{}`, found `{}`".
0 commit comments