@@ -14,7 +14,7 @@ use hair::cx::Cx;
1414use hair:: cx:: block;
1515use hair:: cx:: to_ref:: ToRef ;
1616use rustc:: hir:: def:: { Def , CtorKind } ;
17- use rustc:: mir:: interpret:: GlobalId ;
17+ use rustc:: mir:: interpret:: { GlobalId , ConstValue } ;
1818use rustc:: ty:: { self , AdtKind , Ty } ;
1919use rustc:: ty:: adjustment:: { Adjustment , Adjust , AutoBorrow , AutoBorrowMutability } ;
2020use rustc:: ty:: cast:: CastKind as TyCastKind ;
@@ -760,7 +760,22 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
760760 ) ,
761761 } ,
762762
763- Def :: ConstParam ( def_id) |
763+ Def :: ConstParam ( def_id) => {
764+ let node_id = cx. tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
765+ let item_id = cx. tcx . hir . get_parent_node ( node_id) ;
766+ let item_def_id = cx. tcx . hir . local_def_id ( item_id) ;
767+ let generics = cx. tcx . generics_of ( item_def_id) ;
768+ let index = generics. param_def_id_to_index [ & cx. tcx . hir . local_def_id ( node_id) ] ;
769+ let name = cx. tcx . hir . name ( node_id) . as_interned_str ( ) ;
770+ let val = ConstValue :: Param ( ty:: ParamConst :: new ( index, name) ) ;
771+ ExprKind :: Literal {
772+ literal : cx. tcx . mk_const ( ty:: Const {
773+ val,
774+ ty : cx. tables ( ) . node_id_to_type ( expr. hir_id ) ,
775+ } ) ,
776+ }
777+ }
778+
764779 Def :: Const ( def_id) |
765780 Def :: AssociatedConst ( def_id) => ExprKind :: Literal {
766781 literal : ty:: Const :: unevaluated (
0 commit comments