Skip to content

Commit 9cd8bb0

Browse files
committed
use ParamConst in ExprKind::ConstParam
1 parent e2496b3 commit 9cd8bb0

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

compiler/rustc_middle/src/thir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub enum ExprKind<'tcx> {
424424
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
425425
},
426426
ConstParam {
427-
literal: ty::Const<'tcx>,
427+
param: ty::ParamConst,
428428
def_id: DefId,
429429
},
430430
// FIXME improve docs for `StaticRef` by distinguishing it from `NamedConst`

compiler/rustc_middle/src/thir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
121121
Literal { lit: _, neg: _ } => {}
122122
ScalarLiteral { lit: _, user_ty: _ } => {}
123123
NamedConst { def_id: _, substs: _, user_ty: _ } => {}
124-
ConstParam { literal: _, def_id: _ } => {}
124+
ConstParam { param: _, def_id: _ } => {}
125125
StaticRef { alloc_id: _, ty: _, def_id: _ } => {}
126126
InlineAsm { ref operands, template: _, options: _, line_spans: _ } => {
127127
for op in &**operands {

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7070

7171
Constant { user_ty, span, literal }
7272
}
73-
ExprKind::ConstParam { literal, def_id: _ } => {
74-
let literal = ConstantKind::Ty(literal);
73+
ExprKind::ConstParam { param, def_id: _ } => {
74+
let const_param =
75+
tcx.mk_const(ty::ConstS { val: ty::ConstKind::Param(param), ty: expr.ty });
76+
let literal = ConstantKind::Ty(const_param);
7577

7678
Constant { user_ty: None, span, literal }
7779
}

compiler/rustc_mir_build/src/thir/cx/expr.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,9 @@ impl<'tcx> Cx<'tcx> {
869869
let generics = self.tcx.generics_of(item_def_id);
870870
let index = generics.param_def_id_to_index[&def_id];
871871
let name = self.tcx.hir().name(hir_id);
872-
let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
873-
874-
ExprKind::ConstParam {
875-
literal: self.tcx.mk_const(ty::ConstS {
876-
val,
877-
ty: self.typeck_results().node_type(expr.hir_id),
878-
}),
879-
def_id,
880-
}
872+
let param = ty::ParamConst::new(index, name);
873+
874+
ExprKind::ConstParam { param, def_id }
881875
}
882876

883877
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,12 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
459459
self.nodes.push(Node::Leaf(constant))
460460
}
461461

462-
ExprKind::ConstParam {literal, ..} => {
463-
self.nodes.push(Node::Leaf(*literal))
462+
ExprKind::ConstParam {param, ..} => {
463+
let const_param = self.tcx.mk_const(ty::ConstS {
464+
val: ty::ConstKind::Param(*param),
465+
ty: node.ty,
466+
});
467+
self.nodes.push(Node::Leaf(const_param))
464468
}
465469

466470
ExprKind::Call { fun, args, .. } => {

0 commit comments

Comments
 (0)