@@ -271,10 +271,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
271
271
// Tuple-like ADTs are represented as ExprCall. We convert them here.
272
272
expr_ty. ty_adt_def ( ) . and_then ( |adt_def|{
273
273
match cx. tcx . expect_def ( fun. id ) {
274
- Def :: VariantCtor ( variant_id, .. ) => {
274
+ Def :: VariantCtor ( variant_id, CtorKind :: Fn ) => {
275
275
Some ( ( adt_def, adt_def. variant_index_with_id ( variant_id) ) )
276
276
} ,
277
- Def :: StructCtor ( .. ) => {
277
+ Def :: StructCtor ( _ , CtorKind :: Fn ) => {
278
278
Some ( ( adt_def, 0 ) )
279
279
} ,
280
280
_ => None
@@ -670,38 +670,25 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
670
670
// Otherwise there may be def_map borrow conflicts
671
671
let def = cx. tcx . expect_def ( expr. id ) ;
672
672
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) |
675
675
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.
680
683
ty:: TyAdt ( adt_def, substs) => return ExprKind :: Adt {
681
684
adt_def : adt_def,
682
- variant_index : 0 ,
685
+ variant_index : adt_def . variant_index_with_id ( def_id ) ,
683
686
substs : substs,
684
687
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 ,
700
689
} ,
701
690
ref sty => bug ! ( "unexpected sty: {:?}" , sty)
702
691
} ,
703
- Def :: Const ( def_id) |
704
- Def :: AssociatedConst ( def_id) => def_id,
705
692
706
693
Def :: Static ( node_id, _) => return ExprKind :: StaticRef {
707
694
id : node_id,
0 commit comments