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