@@ -633,14 +633,12 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
633633 tcx. ensure ( ) . predicates_of ( def_id) ;
634634
635635 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 ) ;
640639 }
641640
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 ( ) {
644642 convert_variant_ctor ( tcx, ctor_def_id) ;
645643 }
646644 }
@@ -817,7 +815,6 @@ fn convert_variant(
817815 . fields ( )
818816 . iter ( )
819817 . map ( |f| {
820- let fid = tcx. hir ( ) . local_def_id ( f. hir_id ) ;
821818 let dup_span = seen_fields. get ( & f. ident . normalize_to_macros_2_0 ( ) ) . cloned ( ) ;
822819 if let Some ( prev_span) = dup_span {
823820 tcx. sess . emit_err ( errors:: FieldAlreadyDeclared {
@@ -829,7 +826,11 @@ fn convert_variant(
829826 seen_fields. insert ( f. ident . normalize_to_macros_2_0 ( ) , f. span ) ;
830827 }
831828
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+ }
833834 } )
834835 . collect ( ) ;
835836 let recovered = match def {
@@ -870,10 +871,6 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
870871 . variants
871872 . iter ( )
872873 . 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-
877874 let discr = if let Some ( ref e) = v. disr_expr {
878875 distance_from_explicit = 0 ;
879876 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> {
884881
885882 convert_variant (
886883 tcx,
887- variant_did ,
888- ctor_did ,
884+ Some ( v . def_id ) ,
885+ v . data . ctor_def_id ( ) ,
889886 v. ident ,
890887 discr,
891888 & v. data ,
@@ -898,13 +895,10 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
898895 ( AdtKind :: Enum , variants)
899896 }
900897 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-
904898 let variants = std:: iter:: once ( convert_variant (
905899 tcx,
906- variant_did ,
907- ctor_did ,
900+ None ,
901+ def . ctor_def_id ( ) ,
908902 item. ident ,
909903 ty:: VariantDiscr :: Relative ( 0 ) ,
910904 def,
@@ -916,13 +910,10 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
916910 ( AdtKind :: Struct , variants)
917911 }
918912 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-
922913 let variants = std:: iter:: once ( convert_variant (
923914 tcx,
924- variant_did ,
925- ctor_did ,
915+ None ,
916+ def . ctor_def_id ( ) ,
926917 item. ident ,
927918 ty:: VariantDiscr :: Relative ( 0 ) ,
928919 def,
@@ -1182,8 +1173,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
11821173
11831174 Ctor ( data) | Variant ( hir:: Variant { data, .. } ) if data. ctor_hir_id ( ) . is_some ( ) => {
11841175 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 ) ) ;
11871177 ty:: Binder :: dummy ( tcx. mk_fn_sig (
11881178 inputs,
11891179 ty,
0 commit comments