@@ -271,10 +271,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
271271 // Tuple-like ADTs are represented as ExprCall. We convert them here.
272272 expr_ty. ty_adt_def ( ) . and_then ( |adt_def|{
273273 match cx. tcx . expect_def ( fun. id ) {
274- Def :: VariantCtor ( variant_id, .. ) => {
274+ Def :: VariantCtor ( variant_id, CtorKind :: Fn ) => {
275275 Some ( ( adt_def, adt_def. variant_index_with_id ( variant_id) ) )
276276 } ,
277- Def :: StructCtor ( .. ) => {
277+ Def :: StructCtor ( _ , CtorKind :: Fn ) => {
278278 Some ( ( adt_def, 0 ) )
279279 } ,
280280 _ => None
@@ -670,38 +670,25 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
670670 // Otherwise there may be def_map borrow conflicts
671671 let def = cx. tcx . expect_def ( expr. id ) ;
672672 let def_id = match def {
673- // A regular function.
674- Def :: Fn ( def_id) | Def :: Method ( def_id) => def_id ,
673+ // A regular function, constructor function or a constant .
674+ Def :: Fn ( def_id) | Def :: Method ( def_id) |
675675 Def :: StructCtor ( def_id, CtorKind :: Fn ) |
676- Def :: VariantCtor ( def_id, CtorKind :: Fn ) => def_id,
677- Def :: StructCtor ( _, CtorKind :: Const ) => match cx. tcx . node_id_to_type ( expr. id ) . sty {
678- // A unit struct which is used as a value. We return a completely different ExprKind
679- // here to account for this special case.
676+ Def :: VariantCtor ( def_id, CtorKind :: Fn ) |
677+ Def :: Const ( def_id) | Def :: AssociatedConst ( def_id) => def_id,
678+
679+ Def :: StructCtor ( def_id, CtorKind :: Const ) |
680+ Def :: VariantCtor ( def_id, CtorKind :: Const ) => match cx. tcx . node_id_to_type ( expr. id ) . sty {
681+ // A unit struct/variant which is used as a value.
682+ // We return a completely different ExprKind here to account for this special case.
680683 ty:: TyAdt ( adt_def, substs) => return ExprKind :: Adt {
681684 adt_def : adt_def,
682- variant_index : 0 ,
685+ variant_index : adt_def . variant_index_with_id ( def_id ) ,
683686 substs : substs,
684687 fields : vec ! [ ] ,
685- base : None
686- } ,
687- ref sty => bug ! ( "unexpected sty: {:?}" , sty)
688- } ,
689- Def :: VariantCtor ( def_id, CtorKind :: Const ) => match cx. tcx . node_id_to_type ( expr. id ) . sty {
690- // A unit variant, similar special case to the struct case above.
691- ty:: TyAdt ( adt_def, substs) => {
692- let index = adt_def. variant_index_with_id ( def_id) ;
693- return ExprKind :: Adt {
694- adt_def : adt_def,
695- substs : substs,
696- variant_index : index,
697- fields : vec ! [ ] ,
698- base : None
699- } ;
688+ base : None ,
700689 } ,
701690 ref sty => bug ! ( "unexpected sty: {:?}" , sty)
702691 } ,
703- Def :: Const ( def_id) |
704- Def :: AssociatedConst ( def_id) => def_id,
705692
706693 Def :: Static ( node_id, _) => return ExprKind :: StaticRef {
707694 id : node_id,
0 commit comments