提交 9cd8bb04 编写于 作者: B b-naber

use ParamConst in ExprKind::ConstParam

上级 e2496b3c
......@@ -424,7 +424,7 @@ pub enum ExprKind<'tcx> {
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`
......
......@@ -121,7 +121,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
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 {
......
......@@ -70,8 +70,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
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 }
}
......
......@@ -869,15 +869,9 @@ fn convert_path_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, res: Res) -> ExprKi
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) => {
......
......@@ -459,8 +459,12 @@ fn recurse_build(&mut self, node: thir::ExprId) -> Result<NodeId, ErrorGuarantee
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, .. } => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册