user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
},
ConstParam {
- literal: ty::Const<'tcx>,
+ param: ty::ParamConst,
def_id: DefId,
},
// FIXME improve docs for `StaticRef` by distinguishing it from `NamedConst`
Literal { lit: _, neg: _ } => {}
ScalarLiteral { lit: _, user_ty: _ } => {}
NamedConst { def_id: _, substs: _, user_ty: _ } => {}
- ConstParam { literal: _, def_id: _ } => {}
+ ConstParam { param: _, def_id: _ } => {}
StaticRef { alloc_id: _, ty: _, def_id: _ } => {}
InlineAsm { ref operands, template: _, options: _, line_spans: _ } => {
for op in &**operands {
Constant { user_ty, span, literal }
}
- ExprKind::ConstParam { literal, def_id: _ } => {
- let literal = ConstantKind::Ty(literal);
+ ExprKind::ConstParam { param, def_id: _ } => {
+ let const_param =
+ tcx.mk_const(ty::ConstS { val: ty::ConstKind::Param(param), ty: expr.ty });
+ let literal = ConstantKind::Ty(const_param);
Constant { user_ty: None, span, literal }
}
let generics = self.tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id];
let name = self.tcx.hir().name(hir_id);
- let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
-
- ExprKind::ConstParam {
- literal: self.tcx.mk_const(ty::ConstS {
- val,
- ty: self.typeck_results().node_type(expr.hir_id),
- }),
- def_id,
- }
+ let param = ty::ParamConst::new(index, name);
+
+ ExprKind::ConstParam { param, def_id }
}
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
self.nodes.push(Node::Leaf(constant))
}
- ExprKind::ConstParam {literal, ..} => {
- self.nodes.push(Node::Leaf(*literal))
+ ExprKind::ConstParam {param, ..} => {
+ let const_param = self.tcx.mk_const(ty::ConstS {
+ val: ty::ConstKind::Param(*param),
+ ty: node.ty,
+ });
+ self.nodes.push(Node::Leaf(const_param))
}
ExprKind::Call { fun, args, .. } => {