@@ -24,7 +24,6 @@ use rustc_data_structures::captures::Captures;
2424use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
2525use rustc_errors:: { struct_span_err, Applicability , DiagnosticBuilder , ErrorGuaranteed , StashKey } ;
2626use rustc_hir as hir;
27- use rustc_hir:: def:: CtorKind ;
2827use rustc_hir:: def_id:: { DefId , LocalDefId , LOCAL_CRATE } ;
2928use rustc_hir:: intravisit:: { self , Visitor } ;
3029use rustc_hir:: weak_lang_items:: WEAK_LANG_ITEMS ;
@@ -794,7 +793,7 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
794793
795794 // Convert the ctor, if any. This also registers the variant as
796795 // an item.
797- if let Some ( ctor_def_id) = variant. ctor_def_id {
796+ if let Some ( ctor_def_id) = variant. ctor_def_id ( ) {
798797 convert_variant_ctor ( tcx, ctor_def_id. expect_local ( ) ) ;
799798 }
800799 }
@@ -803,7 +802,6 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
803802fn convert_variant (
804803 tcx : TyCtxt < ' _ > ,
805804 variant_did : Option < LocalDefId > ,
806- ctor_did : Option < LocalDefId > ,
807805 ident : Ident ,
808806 discr : ty:: VariantDiscr ,
809807 def : & hir:: VariantData < ' _ > ,
@@ -840,10 +838,9 @@ fn convert_variant(
840838 ty:: VariantDef :: new (
841839 ident. name ,
842840 variant_did. map ( LocalDefId :: to_def_id) ,
843- ctor_did . map ( LocalDefId :: to_def_id) ,
841+ def . ctor ( ) . map ( | ( kind , _ , def_id ) | ( kind , def_id . to_def_id ( ) ) ) ,
844842 discr,
845843 fields,
846- CtorKind :: from_hir ( def) ,
847844 adt_kind,
848845 parent_did. to_def_id ( ) ,
849846 recovered,
@@ -882,7 +879,6 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
882879 convert_variant (
883880 tcx,
884881 Some ( v. def_id ) ,
885- v. data . ctor_def_id ( ) ,
886882 v. ident ,
887883 discr,
888884 & v. data ,
@@ -894,35 +890,23 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::AdtDef<'tcx> {
894890
895891 ( AdtKind :: Enum , variants)
896892 }
897- ItemKind :: Struct ( ref def, _) => {
898- let variants = std:: iter:: once ( convert_variant (
899- tcx,
900- None ,
901- def. ctor_def_id ( ) ,
902- item. ident ,
903- ty:: VariantDiscr :: Relative ( 0 ) ,
904- def,
905- AdtKind :: Struct ,
906- def_id,
907- ) )
908- . collect ( ) ;
909-
910- ( AdtKind :: Struct , variants)
911- }
912- ItemKind :: Union ( ref def, _) => {
893+ ItemKind :: Struct ( ref def, _) | ItemKind :: Union ( ref def, _) => {
894+ let adt_kind = match item. kind {
895+ ItemKind :: Struct ( ..) => AdtKind :: Struct ,
896+ _ => AdtKind :: Union ,
897+ } ;
913898 let variants = std:: iter:: once ( convert_variant (
914899 tcx,
915900 None ,
916- def. ctor_def_id ( ) ,
917901 item. ident ,
918902 ty:: VariantDiscr :: Relative ( 0 ) ,
919903 def,
920- AdtKind :: Union ,
904+ adt_kind ,
921905 def_id,
922906 ) )
923907 . collect ( ) ;
924908
925- ( AdtKind :: Union , variants)
909+ ( adt_kind , variants)
926910 }
927911 _ => bug ! ( ) ,
928912 } ;
@@ -1171,7 +1155,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
11711155 compute_sig_of_foreign_fn_decl ( tcx, def_id. to_def_id ( ) , fn_decl, abi)
11721156 }
11731157
1174- Ctor ( data) | Variant ( hir:: Variant { data, .. } ) if data. ctor_hir_id ( ) . is_some ( ) => {
1158+ Ctor ( data) | Variant ( hir:: Variant { data, .. } ) if data. ctor ( ) . is_some ( ) => {
11751159 let ty = tcx. type_of ( tcx. hir ( ) . get_parent_item ( hir_id) ) ;
11761160 let inputs = data. fields ( ) . iter ( ) . map ( |f| tcx. type_of ( f. def_id ) ) ;
11771161 ty:: Binder :: dummy ( tcx. mk_fn_sig (
0 commit comments