4545//! ported to this system, and which relies on string concatenation at the
4646//! time of error detection.
4747
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} ;
5752
58- use crate :: infer:: relate:: { self , RelateResult , TypeRelation } ;
5953use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
6054use rustc_errors:: {
6155 pluralize, Applicability , Diag , DiagCtxtHandle , DiagStyledString , IntoDiagArg , StringPart ,
@@ -68,6 +62,7 @@ use rustc_hir::{self as hir};
6862use rustc_macros:: extension;
6963use rustc_middle:: bug;
7064use rustc_middle:: dep_graph:: DepContext ;
65+ use rustc_middle:: ty:: error:: ExpectedFound ;
7166use rustc_middle:: ty:: error:: TypeErrorToStringExt ;
7267use rustc_middle:: ty:: print:: { with_forced_trimmed_paths, PrintError , PrintTraitRefExt as _} ;
7368use rustc_middle:: ty:: {
@@ -76,18 +71,21 @@ use rustc_middle::ty::{
7671} ;
7772use rustc_span:: { sym, BytePos , DesugaringKind , Pos , Span } ;
7873use 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+ } ;
8383
8484mod note_and_explain;
8585mod suggest;
8686
87- pub ( crate ) mod need_type_info;
88- pub mod sub_relations;
89- pub use need_type_info:: TypeAnnotationNeeded ;
9087pub mod region;
88+ pub mod sub_relations;
9189
9290pub mod nice_region_error;
9391
@@ -1242,7 +1240,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12421240 Some ( values) => {
12431241 let values = self . resolve_vars_if_possible ( values) ;
12441242 let ( is_simple_error, exp_found) = match values {
1245- ValuePairs :: Terms ( infer :: ExpectedFound { expected, found } ) => {
1243+ ValuePairs :: Terms ( ExpectedFound { expected, found } ) => {
12461244 match ( expected. unpack ( ) , found. unpack ( ) ) {
12471245 ( ty:: TermKind :: Ty ( expected) , ty:: TermKind :: Ty ( found) ) => {
12481246 let is_simple_err = expected. is_simple_text ( self . tcx )
@@ -1254,7 +1252,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12541252
12551253 (
12561254 is_simple_err,
1257- Mismatch :: Variable ( infer :: ExpectedFound { expected, found } ) ,
1255+ Mismatch :: Variable ( ExpectedFound { expected, found } ) ,
12581256 )
12591257 }
12601258 ( ty:: TermKind :: Const ( _) , ty:: TermKind :: Const ( _) ) => {
@@ -1263,13 +1261,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12631261 _ => ( false , Mismatch :: Fixed ( "type" ) ) ,
12641262 }
12651263 }
1266- ValuePairs :: PolySigs ( infer :: ExpectedFound { expected, found } ) => {
1264+ ValuePairs :: PolySigs ( ExpectedFound { expected, found } ) => {
12671265 OpaqueTypesVisitor :: visit_expected_found ( self . tcx , expected, found, span)
12681266 . report ( diag) ;
12691267 ( false , Mismatch :: Fixed ( "signature" ) )
12701268 }
12711269 ValuePairs :: TraitRefs ( _) => ( false , Mismatch :: Fixed ( "trait" ) ) ,
1272- ValuePairs :: Aliases ( infer :: ExpectedFound { expected, .. } ) => {
1270+ ValuePairs :: Aliases ( ExpectedFound { expected, .. } ) => {
12731271 ( false , Mismatch :: Fixed ( self . tcx . def_descr ( expected. def_id ) ) )
12741272 }
12751273 ValuePairs :: Regions ( _) => ( false , Mismatch :: Fixed ( "lifetime" ) ) ,
@@ -1303,9 +1301,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13031301 } ;
13041302 if let Some ( ( sp, msg) ) = secondary_span {
13051303 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, ..
13091306 } ) ) = values
13101307 {
13111308 Cow :: from ( format ! ( "expected this to be `{expected}`" ) )
0 commit comments