@@ -13,6 +13,7 @@ use rustc_data_structures::indexed_vec::Idx;
1313use hair:: cx:: Cx ;
1414use hair:: cx:: block;
1515use hair:: cx:: to_ref:: ToRef ;
16+ use hair:: util:: UserAnnotatedTyHelpers ;
1617use rustc:: hir:: def:: { Def , CtorKind } ;
1718use rustc:: mir:: interpret:: GlobalId ;
1819use rustc:: ty:: { self , AdtKind , Ty } ;
@@ -475,7 +476,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
475476 adt_def : adt,
476477 variant_index : 0 ,
477478 substs,
478- user_ty : user_annotated_ty_for_adt ( cx , expr. hir_id , adt) ,
479+ user_ty : cx . user_substs_applied_to_adt ( expr. hir_id , adt) ,
479480 fields : field_refs ( cx, fields) ,
480481 base : base. as_ref ( ) . map ( |base| {
481482 FruInfo {
@@ -501,7 +502,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
501502 adt_def : adt,
502503 variant_index : index,
503504 substs,
504- user_ty : user_annotated_ty_for_adt ( cx , expr. hir_id , adt) ,
505+ user_ty : cx . user_substs_applied_to_adt ( expr. hir_id , adt) ,
505506 fields : field_refs ( cx, fields) ,
506507 base : None ,
507508 }
@@ -787,48 +788,17 @@ fn user_annotated_ty_for_def(
787788 // user.
788789 Def :: StructCtor ( _def_id, CtorKind :: Const ) |
789790 Def :: VariantCtor ( _def_id, CtorKind :: Const ) =>
790- match & cx. tables ( ) . node_id_to_type ( hir_id) . sty {
791- ty:: Adt ( adt_def, _) => user_annotated_ty_for_adt ( cx, hir_id, adt_def) ,
792- sty => bug ! ( "unexpected sty: {:?}" , sty) ,
793- } ,
791+ cx. user_substs_applied_to_ty_of_hir_id ( hir_id) ,
794792
795793 // `Self` is used in expression as a tuple struct constructor or an unit struct constructor
796- Def :: SelfCtor ( _) => {
797- let sty = & cx. tables ( ) . node_id_to_type ( hir_id) . sty ;
798- match sty {
799- ty:: FnDef ( ref def_id, _) => {
800- Some ( cx. tables ( ) . user_substs ( hir_id) ?. unchecked_map ( |user_substs| {
801- // Here, we just pair a `DefId` with the
802- // `user_substs`, so no new types etc are introduced.
803- cx. tcx ( ) . mk_fn_def ( * def_id, user_substs)
804- } ) )
805- }
806- ty:: Adt ( ref adt_def, _) => {
807- user_annotated_ty_for_adt ( cx, hir_id, adt_def)
808- }
809- _ => {
810- bug ! ( "unexpected sty: {:?}" , sty)
811- }
812- }
813- }
794+ Def :: SelfCtor ( _) =>
795+ cx. user_substs_applied_to_ty_of_hir_id ( hir_id) ,
796+
814797 _ =>
815798 bug ! ( "user_annotated_ty_for_def: unexpected def {:?} at {:?}" , def, hir_id)
816799 }
817800}
818801
819- fn user_annotated_ty_for_adt (
820- cx : & mut Cx < ' a , ' gcx , ' tcx > ,
821- hir_id : hir:: HirId ,
822- adt_def : & ' tcx AdtDef ,
823- ) -> Option < CanonicalTy < ' tcx > > {
824- let user_substs = cx. tables ( ) . user_substs ( hir_id) ?;
825- Some ( user_substs. unchecked_map ( |user_substs| {
826- // Here, we just pair an `AdtDef` with the
827- // `user_substs`, so no new types etc are introduced.
828- cx. tcx ( ) . mk_adt ( adt_def, user_substs)
829- } ) )
830- }
831-
832802fn method_callee < ' a , ' gcx , ' tcx > (
833803 cx : & mut Cx < ' a , ' gcx , ' tcx > ,
834804 expr : & hir:: Expr ,
@@ -943,7 +913,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
943913 adt_def,
944914 variant_index : adt_def. variant_index_with_id ( def_id) ,
945915 substs,
946- user_ty : user_annotated_ty_for_adt ( cx , expr. hir_id , adt_def) ,
916+ user_ty : cx . user_substs_applied_to_adt ( expr. hir_id , adt_def) ,
947917 fields : vec ! [ ] ,
948918 base : None ,
949919 }
0 commit comments