45
45
//! ported to this system, and which relies on string concatenation at the
46
46
//! time of error detection.
47
47
48
- use super :: { InferCtxt , TypeTrace , ValuePairs } ;
49
-
50
- use crate :: errors:: { ObligationCauseFailureCode , TypeErrorAdditionalDiags } ;
51
- use crate :: infer;
52
- use crate :: infer:: ExpectedFound ;
53
- use crate :: traits:: {
54
- IfExpressionCause , MatchExpressionArmCause , ObligationCause , ObligationCauseCode ,
55
- PredicateObligation ,
56
- } ;
48
+ use std:: borrow:: Cow ;
49
+ use std:: ops:: { ControlFlow , Deref } ;
50
+ use std:: path:: PathBuf ;
51
+ use std:: { cmp, fmt, iter} ;
57
52
58
- use crate :: infer:: relate:: { self , RelateResult , TypeRelation } ;
59
53
use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
60
54
use rustc_errors:: {
61
55
pluralize, Applicability , Diag , DiagCtxtHandle , DiagStyledString , IntoDiagArg , StringPart ,
@@ -68,6 +62,7 @@ use rustc_hir::{self as hir};
68
62
use rustc_macros:: extension;
69
63
use rustc_middle:: bug;
70
64
use rustc_middle:: dep_graph:: DepContext ;
65
+ use rustc_middle:: ty:: error:: ExpectedFound ;
71
66
use rustc_middle:: ty:: error:: TypeErrorToStringExt ;
72
67
use rustc_middle:: ty:: print:: { with_forced_trimmed_paths, PrintError , PrintTraitRefExt as _} ;
73
68
use rustc_middle:: ty:: {
@@ -76,18 +71,21 @@ use rustc_middle::ty::{
76
71
} ;
77
72
use rustc_span:: { sym, BytePos , DesugaringKind , Pos , Span } ;
78
73
use rustc_target:: spec:: abi;
79
- use std:: borrow:: Cow ;
80
- use std:: ops:: { ControlFlow , Deref } ;
81
- use std:: path:: PathBuf ;
82
- use std:: { cmp, fmt, iter} ;
74
+
75
+ use crate :: errors:: { ObligationCauseFailureCode , TypeErrorAdditionalDiags } ;
76
+ use crate :: infer;
77
+ use crate :: infer:: relate:: { self , RelateResult , TypeRelation } ;
78
+ use crate :: infer:: { InferCtxt , TypeTrace , ValuePairs } ;
79
+ use crate :: traits:: {
80
+ IfExpressionCause , MatchExpressionArmCause , ObligationCause , ObligationCauseCode ,
81
+ PredicateObligation ,
82
+ } ;
83
83
84
84
mod note_and_explain;
85
85
mod suggest;
86
86
87
- pub ( crate ) mod need_type_info;
88
- pub mod sub_relations;
89
- pub use need_type_info:: TypeAnnotationNeeded ;
90
87
pub mod region;
88
+ pub mod sub_relations;
91
89
92
90
pub mod nice_region_error;
93
91
@@ -1242,7 +1240,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1242
1240
Some ( values) => {
1243
1241
let values = self . resolve_vars_if_possible ( values) ;
1244
1242
let ( is_simple_error, exp_found) = match values {
1245
- ValuePairs :: Terms ( infer :: ExpectedFound { expected, found } ) => {
1243
+ ValuePairs :: Terms ( ExpectedFound { expected, found } ) => {
1246
1244
match ( expected. unpack ( ) , found. unpack ( ) ) {
1247
1245
( ty:: TermKind :: Ty ( expected) , ty:: TermKind :: Ty ( found) ) => {
1248
1246
let is_simple_err = expected. is_simple_text ( self . tcx )
@@ -1254,7 +1252,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1254
1252
1255
1253
(
1256
1254
is_simple_err,
1257
- Mismatch :: Variable ( infer :: ExpectedFound { expected, found } ) ,
1255
+ Mismatch :: Variable ( ExpectedFound { expected, found } ) ,
1258
1256
)
1259
1257
}
1260
1258
( ty:: TermKind :: Const ( _) , ty:: TermKind :: Const ( _) ) => {
@@ -1263,13 +1261,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1263
1261
_ => ( false , Mismatch :: Fixed ( "type" ) ) ,
1264
1262
}
1265
1263
}
1266
- ValuePairs :: PolySigs ( infer :: ExpectedFound { expected, found } ) => {
1264
+ ValuePairs :: PolySigs ( ExpectedFound { expected, found } ) => {
1267
1265
OpaqueTypesVisitor :: visit_expected_found ( self . tcx , expected, found, span)
1268
1266
. report ( diag) ;
1269
1267
( false , Mismatch :: Fixed ( "signature" ) )
1270
1268
}
1271
1269
ValuePairs :: TraitRefs ( _) => ( false , Mismatch :: Fixed ( "trait" ) ) ,
1272
- ValuePairs :: Aliases ( infer :: ExpectedFound { expected, .. } ) => {
1270
+ ValuePairs :: Aliases ( ExpectedFound { expected, .. } ) => {
1273
1271
( false , Mismatch :: Fixed ( self . tcx . def_descr ( expected. def_id ) ) )
1274
1272
}
1275
1273
ValuePairs :: Regions ( _) => ( false , Mismatch :: Fixed ( "lifetime" ) ) ,
@@ -1303,9 +1301,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1303
1301
} ;
1304
1302
if let Some ( ( sp, msg) ) = secondary_span {
1305
1303
if swap_secondary_and_primary {
1306
- let terr = if let Some ( infer:: ValuePairs :: Terms ( infer:: ExpectedFound {
1307
- expected,
1308
- ..
1304
+ let terr = if let Some ( infer:: ValuePairs :: Terms ( ExpectedFound {
1305
+ expected, ..
1309
1306
} ) ) = values
1310
1307
{
1311
1308
Cow :: from ( format ! ( "expected this to be `{expected}`" ) )
0 commit comments