@@ -15,6 +15,7 @@ pub use self::AssocItemContainer::*;
1515pub use self :: BorrowKind :: * ;
1616pub use self :: IntVarValue :: * ;
1717pub use self :: Variance :: * ;
18+ use crate :: error:: { OpaqueHiddenTypeMismatch , TypeMismatchReason } ;
1819use crate :: metadata:: ModChild ;
1920use crate :: middle:: privacy:: AccessLevels ;
2021use crate :: mir:: { Body , GeneratorLayout } ;
@@ -1179,20 +1180,17 @@ pub struct OpaqueHiddenType<'tcx> {
11791180impl < ' tcx > OpaqueHiddenType < ' tcx > {
11801181 pub fn report_mismatch ( & self , other : & Self , tcx : TyCtxt < ' tcx > ) {
11811182 // 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 }
11921185 } 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+ } ) ;
11961194 }
11971195}
11981196
@@ -2269,7 +2267,11 @@ impl<'tcx> TyCtxt<'tcx> {
22692267 }
22702268
22712269 pub fn get_attr ( self , did : DefId , attr : Symbol ) -> Option < & ' tcx ast:: Attribute > {
2272- self . get_attrs ( did, attr) . next ( )
2270+ if cfg ! ( debug_assertions) && !rustc_feature:: is_valid_for_get_attr ( attr) {
2271+ bug ! ( "get_attr: unexpected called with DefId `{:?}`, attr `{:?}`" , did, attr) ;
2272+ } else {
2273+ self . get_attrs ( did, attr) . next ( )
2274+ }
22732275 }
22742276
22752277 /// Determines whether an item is annotated with an attribute.
0 commit comments