@@ -32,8 +32,6 @@ use rustc_span::symbol::{kw, Ident};
3232use rustc_span:: { self , sym, Span } ;
3333use rustc_trait_selection:: traits:: { self , ObligationCauseCode , SelectionContext } ;
3434
35- use either:: Either ;
36-
3735use std:: iter;
3836use std:: mem;
3937use std:: ops:: ControlFlow ;
@@ -1233,44 +1231,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12331231 ) ;
12341232 return None ;
12351233 }
1236- Res :: Def ( DefKind :: Variant , _) => match ( ty. raw . kind ( ) , ty. normalized . kind ( ) ) {
1237- ( ty:: Adt ( adt, substs) , _) => {
1238- Some ( ( adt. variant_of_res ( def) , adt. did ( ) , substs, Either :: Left ( substs) ) )
1239- }
1240- ( _, ty:: Adt ( adt, substs) ) => {
1241- Some ( ( adt. variant_of_res ( def) , adt. did ( ) , substs, Either :: Right ( ty. raw ) ) )
1234+ Res :: Def ( DefKind :: Variant , _) => match ty. normalized . ty_adt_def ( ) {
1235+ Some ( adt) => {
1236+ Some ( ( adt. variant_of_res ( def) , adt. did ( ) , Self :: user_substs_for_adt ( ty) ) )
12421237 }
12431238 _ => bug ! ( "unexpected type: {:?}" , ty. normalized) ,
12441239 } ,
12451240 Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: TyAlias | DefKind :: AssocTy , _)
12461241 | Res :: SelfTyParam { .. }
1247- | Res :: SelfTyAlias { .. } => match ( ty. raw . kind ( ) , ty. normalized . kind ( ) ) {
1248- ( ty:: Adt ( adt, substs) , _) if !adt. is_enum ( ) => {
1249- Some ( ( adt. non_enum_variant ( ) , adt. did ( ) , substs, Either :: Left ( substs) ) )
1250- }
1251- ( _, ty:: Adt ( adt, substs) ) if !adt. is_enum ( ) => {
1252- Some ( ( adt. non_enum_variant ( ) , adt. did ( ) , substs, Either :: Right ( ty. raw ) ) )
1242+ | Res :: SelfTyAlias { .. } => match ty. normalized . ty_adt_def ( ) {
1243+ Some ( adt) if !adt. is_enum ( ) => {
1244+ Some ( ( adt. non_enum_variant ( ) , adt. did ( ) , Self :: user_substs_for_adt ( ty) ) )
12531245 }
12541246 _ => None ,
12551247 } ,
12561248 _ => bug ! ( "unexpected definition: {:?}" , def) ,
12571249 } ;
12581250
1259- if let Some ( ( variant, did, substs, user_annotation ) ) = variant {
1251+ if let Some ( ( variant, did, ty :: UserSubsts { substs, user_self_ty } ) ) = variant {
12601252 debug ! ( "check_struct_path: did={:?} substs={:?}" , did, substs) ;
12611253
12621254 // Register type annotation.
1263- self . probe ( |_| {
1264- // UserSubsts and UserSelfTy are mutually exclusive here.
1265- let ( user_substs, self_ty) = match user_annotation {
1266- Either :: Left ( substs) => ( * substs, None ) ,
1267- Either :: Right ( self_ty) => {
1268- ( self . fresh_substs_for_item ( path_span, did) , Some ( self_ty) )
1269- }
1270- } ;
1271- let self_ty = self_ty. map ( |self_ty| ty:: UserSelfTy { impl_def_id : did, self_ty } ) ;
1272- self . write_user_type_annotation_from_substs ( hir_id, did, user_substs, self_ty) ;
1273- } ) ;
1255+ self . write_user_type_annotation_from_substs ( hir_id, did, substs, user_self_ty) ;
12741256
12751257 // Check bounds on type arguments used in the path.
12761258 self . add_required_obligations_for_hir ( path_span, did, substs, hir_id) ;
0 commit comments