@@ -711,9 +711,8 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
711
711
ty : callee. ty ,
712
712
span : expr. span ,
713
713
kind : ExprKind :: Literal {
714
- literal : Literal :: Item {
715
- def_id : callee. def_id ,
716
- substs : callee. substs ,
714
+ literal : Literal :: Value {
715
+ value : ConstVal :: Function ( callee. def_id , callee. substs ) ,
717
716
} ,
718
717
} ,
719
718
}
@@ -740,22 +739,32 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
740
739
-> ExprKind < ' tcx > {
741
740
let substs = cx. tables ( ) . node_id_item_substs ( expr. id )
742
741
. unwrap_or_else ( || cx. tcx . intern_substs ( & [ ] ) ) ;
743
- let def_id = match def {
742
+ match def {
744
743
// A regular function, constructor function or a constant.
745
744
Def :: Fn ( def_id) |
746
745
Def :: Method ( def_id) |
747
746
Def :: StructCtor ( def_id, CtorKind :: Fn ) |
748
- Def :: VariantCtor ( def_id, CtorKind :: Fn ) |
747
+ Def :: VariantCtor ( def_id, CtorKind :: Fn ) => ExprKind :: Literal {
748
+ literal : Literal :: Value {
749
+ value : ConstVal :: Function ( def_id, substs) ,
750
+ } ,
751
+ } ,
752
+
749
753
Def :: Const ( def_id) |
750
- Def :: AssociatedConst ( def_id) => def_id,
754
+ Def :: AssociatedConst ( def_id) => ExprKind :: Literal {
755
+ literal : Literal :: Item {
756
+ def_id : def_id,
757
+ substs : substs,
758
+ } ,
759
+ } ,
751
760
752
761
Def :: StructCtor ( def_id, CtorKind :: Const ) |
753
762
Def :: VariantCtor ( def_id, CtorKind :: Const ) => {
754
763
match cx. tables ( ) . node_id_to_type ( expr. id ) . sty {
755
764
// A unit struct/variant which is used as a value.
756
765
// We return a completely different ExprKind here to account for this special case.
757
766
ty:: TyAdt ( adt_def, substs) => {
758
- return ExprKind :: Adt {
767
+ ExprKind :: Adt {
759
768
adt_def : adt_def,
760
769
variant_index : adt_def. variant_index_with_id ( def_id) ,
761
770
substs : substs,
@@ -767,17 +776,11 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
767
776
}
768
777
}
769
778
770
- Def :: Static ( node_id, _) => return ExprKind :: StaticRef { id : node_id } ,
779
+ Def :: Static ( node_id, _) => ExprKind :: StaticRef { id : node_id } ,
771
780
772
- Def :: Local ( ..) | Def :: Upvar ( ..) => return convert_var ( cx, expr, def) ,
781
+ Def :: Local ( ..) | Def :: Upvar ( ..) => convert_var ( cx, expr, def) ,
773
782
774
783
_ => span_bug ! ( expr. span, "def `{:?}` not yet implemented" , def) ,
775
- } ;
776
- ExprKind :: Literal {
777
- literal : Literal :: Item {
778
- def_id : def_id,
779
- substs : substs,
780
- } ,
781
784
}
782
785
}
783
786
0 commit comments