@@ -714,9 +714,8 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
714714 ty : callee. ty ,
715715 span : expr. span ,
716716 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 ) ,
720719 } ,
721720 } ,
722721 }
@@ -743,22 +742,32 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
743742 -> ExprKind < ' tcx > {
744743 let substs = cx. tables ( ) . node_id_item_substs ( expr. id )
745744 . unwrap_or_else ( || cx. tcx . intern_substs ( & [ ] ) ) ;
746- let def_id = match def {
745+ match def {
747746 // A regular function, constructor function or a constant.
748747 Def :: Fn ( def_id) |
749748 Def :: Method ( def_id) |
750749 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+
752756 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+ } ,
754763
755764 Def :: StructCtor ( def_id, CtorKind :: Const ) |
756765 Def :: VariantCtor ( def_id, CtorKind :: Const ) => {
757766 match cx. tables ( ) . node_id_to_type ( expr. id ) . sty {
758767 // A unit struct/variant which is used as a value.
759768 // We return a completely different ExprKind here to account for this special case.
760769 ty:: TyAdt ( adt_def, substs) => {
761- return ExprKind :: Adt {
770+ ExprKind :: Adt {
762771 adt_def : adt_def,
763772 variant_index : adt_def. variant_index_with_id ( def_id) ,
764773 substs : substs,
@@ -770,17 +779,11 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
770779 }
771780 }
772781
773- Def :: Static ( node_id, _) => return ExprKind :: StaticRef { id : node_id } ,
782+ Def :: Static ( node_id, _) => ExprKind :: StaticRef { id : node_id } ,
774783
775- Def :: Local ( ..) | Def :: Upvar ( ..) => return convert_var ( cx, expr, def) ,
784+ Def :: Local ( ..) | Def :: Upvar ( ..) => convert_var ( cx, expr, def) ,
776785
777786 _ => 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- } ,
784787 }
785788}
786789
0 commit comments