@@ -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
@@ -2124,9 +2122,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2124
2122
values : ValuePairs < ' tcx > ,
2125
2123
) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
2126
2124
match values {
2127
- infer:: Types ( exp_found) => self . expected_found_str_ty ( exp_found) ,
2128
2125
infer:: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
2129
- infer:: Consts ( exp_found) => self . expected_found_str ( exp_found) ,
2130
2126
infer:: Terms ( exp_found) => self . expected_found_str_term ( exp_found) ,
2131
2127
infer:: TraitRefs ( exp_found) => {
2132
2128
let pretty_exp_found = ty:: error:: ExpectedFound {
@@ -2155,18 +2151,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2155
2151
}
2156
2152
}
2157
2153
2158
- fn expected_found_str_ty (
2159
- & self ,
2160
- exp_found : ty:: error:: ExpectedFound < Ty < ' tcx > > ,
2161
- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString ) > {
2162
- let exp_found = self . resolve_vars_if_possible ( exp_found) ;
2163
- if exp_found. references_error ( ) {
2164
- return None ;
2165
- }
2166
-
2167
- Some ( self . cmp ( exp_found. expected , exp_found. found ) )
2168
- }
2169
-
2170
2154
fn expected_found_str_term (
2171
2155
& self ,
2172
2156
exp_found : ty:: error:: ExpectedFound < ty:: Term < ' tcx > > ,
0 commit comments