diff options
| author | b-naber <bn263@gmx.de> | 2022-03-15 16:32:40 +0100 |
|---|---|---|
| committer | b-naber <bn263@gmx.de> | 2022-03-23 11:34:33 +0100 |
| commit | 9cd8bb045611347e6440baaac5660c2fa0c6cd1b (patch) | |
| tree | a379d52f11f93ca1c03ed94d5b06ec3d53b9e35a | |
| parent | e2496b3cf4a370874bcf4272828730a27f650bc3 (diff) | |
| download | rust-9cd8bb045611347e6440baaac5660c2fa0c6cd1b.tar.gz rust-9cd8bb045611347e6440baaac5660c2fa0c6cd1b.zip | |
use ParamConst in ExprKind::ConstParam
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/thir/visit.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/build/expr/as_constant.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/expr.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/const_evaluatable.rs | 8 |
5 files changed, 15 insertions, 15 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 14ff795b243..ef72e5bcf78 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -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` diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 77e5b8f48d9..bcf316975b6 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -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 { diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/build/expr/as_constant.rs index c02eb40e2cf..2865aceb727 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_constant.rs @@ -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 } } diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index a283c463808..4023e5d4f13 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -869,15 +869,9 @@ impl<'tcx> Cx<'tcx> { 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) => { diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index d26c10ed8f0..d6dd018d46f 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -459,8 +459,12 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { 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, .. } => { |
