@@ -1582,18 +1582,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1582
1582
None => ( None , Mismatch :: Fixed ( "type" ) , false ) ,
1583
1583
Some ( values) => {
1584
1584
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) ;
1595
1592
1596
- ( is_simple_err, Mismatch :: Variable ( exp_found) )
1593
+ (
1594
+ is_simple_err,
1595
+ Mismatch :: Variable ( infer:: ExpectedFound { expected, found } ) ,
1596
+ )
1597
1597
}
1598
1598
ValuePairs :: TraitRefs ( _) => ( false , Mismatch :: Fixed ( "trait" ) ) ,
1599
1599
_ => ( false , Mismatch :: Fixed ( "type" ) ) ,
@@ -1624,7 +1624,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1624
1624
} ;
1625
1625
if let Some ( ( sp, msg) ) = secondary_span {
1626
1626
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 {
1628
1628
expected,
1629
1629
..
1630
1630
} ) ) = values
@@ -2036,9 +2036,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2036
2036
}
2037
2037
FailureCode :: Error0308 ( failure_str) => {
2038
2038
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 ( ) {
2042
2040
match ( expected. kind ( ) , found. kind ( ) ) {
2043
2041
( ty:: Tuple ( _) , ty:: Tuple ( _) ) => { }
2044
2042
// If a tuple of length one was expected and the found expression has
@@ -2148,9 +2146,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2148
2146
values : ValuePairs < ' tcx > ,
2149
2147
) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
2150
2148
match values {
2151
- infer:: Types ( exp_found) => self . expected_found_str_ty ( exp_found) ,
2152
2149
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) ,
2154
2151
infer:: TraitRefs ( exp_found) => {
2155
2152
let pretty_exp_found = ty:: error:: ExpectedFound {
2156
2153
expected : exp_found. expected . print_only_trait_path ( ) ,
@@ -2178,16 +2175,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2178
2175
}
2179
2176
}
2180
2177
2181
- fn expected_found_str_ty (
2178
+ fn expected_found_str_term (
2182
2179
& self ,
2183
- exp_found : ty:: error:: ExpectedFound < Ty < ' tcx > > ,
2180
+ exp_found : ty:: error:: ExpectedFound < ty :: Term < ' tcx > > ,
2184
2181
) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
2185
2182
let exp_found = self . resolve_vars_if_possible ( exp_found) ;
2186
2183
if exp_found. references_error ( ) {
2187
2184
return None ;
2188
2185
}
2189
2186
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
+ } )
2191
2194
}
2192
2195
2193
2196
/// Returns a string of the form "expected `{}`, found `{}`".
0 commit comments