@@ -15,6 +15,7 @@ pub use self::AssocItemContainer::*;
15
15
pub use self :: BorrowKind :: * ;
16
16
pub use self :: IntVarValue :: * ;
17
17
pub use self :: Variance :: * ;
18
+ use crate :: error:: { OpaqueHiddenTypeMismatch , TypeMismatchReason } ;
18
19
use crate :: metadata:: ModChild ;
19
20
use crate :: middle:: privacy:: AccessLevels ;
20
21
use crate :: mir:: { Body , GeneratorLayout } ;
@@ -1179,20 +1180,17 @@ pub struct OpaqueHiddenType<'tcx> {
1179
1180
impl < ' tcx > OpaqueHiddenType < ' tcx > {
1180
1181
pub fn report_mismatch ( & self , other : & Self , tcx : TyCtxt < ' tcx > ) {
1181
1182
// Found different concrete types for the opaque type.
1182
- let mut err = tcx. sess . struct_span_err (
1183
- other. span ,
1184
- "concrete type differs from previous defining opaque type use" ,
1185
- ) ;
1186
- err. span_label ( other. span , format ! ( "expected `{}`, got `{}`" , self . ty, other. ty) ) ;
1187
- if self . span == other. span {
1188
- err. span_label (
1189
- self . span ,
1190
- "this expression supplies two conflicting concrete types for the same opaque type" ,
1191
- ) ;
1183
+ let sub_diag = if self . span == other. span {
1184
+ TypeMismatchReason :: ConflictType { span : self . span }
1192
1185
} else {
1193
- err. span_note ( self . span , "previous use here" ) ;
1194
- }
1195
- err. emit ( ) ;
1186
+ TypeMismatchReason :: PreviousUse { span : self . span }
1187
+ } ;
1188
+ tcx. sess . emit_err ( OpaqueHiddenTypeMismatch {
1189
+ self_ty : self . ty ,
1190
+ other_ty : other. ty ,
1191
+ other_span : other. span ,
1192
+ sub : sub_diag,
1193
+ } ) ;
1196
1194
}
1197
1195
}
1198
1196
0 commit comments