@@ -14,7 +14,7 @@ use hair::cx::Cx;
14
14
use hair:: cx:: block;
15
15
use hair:: cx:: to_ref:: ToRef ;
16
16
use rustc:: hir:: def:: { Def , CtorKind } ;
17
- use rustc:: mir:: interpret:: GlobalId ;
17
+ use rustc:: mir:: interpret:: { GlobalId , ConstValue } ;
18
18
use rustc:: ty:: { self , AdtKind , Ty } ;
19
19
use rustc:: ty:: adjustment:: { Adjustment , Adjust , AutoBorrow , AutoBorrowMutability } ;
20
20
use rustc:: ty:: cast:: CastKind as TyCastKind ;
@@ -760,7 +760,22 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
760
760
) ,
761
761
} ,
762
762
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
+
764
779
Def :: Const ( def_id) |
765
780
Def :: AssociatedConst ( def_id) => ExprKind :: Literal {
766
781
literal : ty:: Const :: unevaluated (
0 commit comments