@@ -633,14 +633,12 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
633
633
tcx. ensure ( ) . predicates_of ( def_id) ;
634
634
635
635
for f in struct_def. fields ( ) {
636
- let def_id = tcx. hir ( ) . local_def_id ( f. hir_id ) ;
637
- tcx. ensure ( ) . generics_of ( def_id) ;
638
- tcx. ensure ( ) . type_of ( def_id) ;
639
- tcx. ensure ( ) . predicates_of ( def_id) ;
636
+ tcx. ensure ( ) . generics_of ( f. def_id ) ;
637
+ tcx. ensure ( ) . type_of ( f. def_id ) ;
638
+ tcx. ensure ( ) . predicates_of ( f. def_id ) ;
640
639
}
641
640
642
- if let Some ( ctor_hir_id) = struct_def. ctor_hir_id ( ) {
643
- let ctor_def_id = tcx. hir ( ) . local_def_id ( ctor_hir_id) ;
641
+ if let Some ( ctor_def_id) = struct_def. ctor_def_id ( ) {
644
642
convert_variant_ctor ( tcx, ctor_def_id) ;
645
643
}
646
644
}
@@ -817,7 +815,6 @@ fn convert_variant(
817
815
. fields ( )
818
816
. iter ( )
819
817
. map ( |f| {
820
- let fid = tcx. hir ( ) . local_def_id ( f. hir_id ) ;
821
818
let dup_span = seen_fields. get ( & f. ident . normalize_to_macros_2_0 ( ) ) . cloned ( ) ;
822
819
if let Some ( prev_span) = dup_span {
823
820
tcx. sess . emit_err ( errors:: FieldAlreadyDeclared {
@@ -829,7 +826,11 @@ fn convert_variant(
829
826
seen_fields. insert ( f. ident . normalize_to_macros_2_0 ( ) , f. span ) ;
830
827
}
831
828
832
- ty:: FieldDef { did : fid. to_def_id ( ) , name : f. ident . name , vis : tcx. visibility ( fid) }
829
+ ty:: FieldDef {
830
+ did : f. def_id . to_def_id ( ) ,
831
+ name : f. ident . name ,
832
+ vis : tcx. visibility ( f. def_id ) ,
833
+ }
833
834
} )
834
835
. collect ( ) ;
835
836
let recovered = match def {
@@ -870,10 +871,6 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
870
871
. variants
871
872
. iter ( )
872
873
. map ( |v| {
873
- let variant_did = Some ( tcx. hir ( ) . local_def_id ( v. id ) ) ;
874
- let ctor_did =
875
- v. data . ctor_hir_id ( ) . map ( |hir_id| tcx. hir ( ) . local_def_id ( hir_id) ) ;
876
-
877
874
let discr = if let Some ( ref e) = v. disr_expr {
878
875
distance_from_explicit = 0 ;
879
876
ty:: VariantDiscr :: Explicit ( e. def_id . to_def_id ( ) )
@@ -884,8 +881,8 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
884
881
885
882
convert_variant (
886
883
tcx,
887
- variant_did ,
888
- ctor_did ,
884
+ Some ( v . def_id ) ,
885
+ v . data . ctor_def_id ( ) ,
889
886
v. ident ,
890
887
discr,
891
888
& v. data ,
@@ -898,13 +895,10 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
898
895
( AdtKind :: Enum , variants)
899
896
}
900
897
ItemKind :: Struct ( ref def, _) => {
901
- let variant_did = None :: < LocalDefId > ;
902
- let ctor_did = def. ctor_hir_id ( ) . map ( |hir_id| tcx. hir ( ) . local_def_id ( hir_id) ) ;
903
-
904
898
let variants = std:: iter:: once ( convert_variant (
905
899
tcx,
906
- variant_did ,
907
- ctor_did ,
900
+ None ,
901
+ def . ctor_def_id ( ) ,
908
902
item. ident ,
909
903
ty:: VariantDiscr :: Relative ( 0 ) ,
910
904
def,
@@ -916,13 +910,10 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
916
910
( AdtKind :: Struct , variants)
917
911
}
918
912
ItemKind :: Union ( ref def, _) => {
919
- let variant_did = None ;
920
- let ctor_did = def. ctor_hir_id ( ) . map ( |hir_id| tcx. hir ( ) . local_def_id ( hir_id) ) ;
921
-
922
913
let variants = std:: iter:: once ( convert_variant (
923
914
tcx,
924
- variant_did ,
925
- ctor_did ,
915
+ None ,
916
+ def . ctor_def_id ( ) ,
926
917
item. ident ,
927
918
ty:: VariantDiscr :: Relative ( 0 ) ,
928
919
def,
@@ -1182,8 +1173,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
1182
1173
1183
1174
Ctor ( data) | Variant ( hir:: Variant { data, .. } ) if data. ctor_hir_id ( ) . is_some ( ) => {
1184
1175
let ty = tcx. type_of ( tcx. hir ( ) . get_parent_item ( hir_id) ) ;
1185
- let inputs =
1186
- data. fields ( ) . iter ( ) . map ( |f| tcx. type_of ( tcx. hir ( ) . local_def_id ( f. hir_id ) ) ) ;
1176
+ let inputs = data. fields ( ) . iter ( ) . map ( |f| tcx. type_of ( f. def_id ) ) ;
1187
1177
ty:: Binder :: dummy ( tcx. mk_fn_sig (
1188
1178
inputs,
1189
1179
ty,
0 commit comments