diff options
| author | Mateusz <mat@gienieczko.com> | 2022-11-04 20:33:32 +0000 |
|---|---|---|
| committer | Mateusz <mat@gienieczko.com> | 2022-11-04 20:33:32 +0000 |
| commit | c97fd8183a98d6a89b8fc2e02eb068298e6fb7dc (patch) | |
| tree | ea41c9f0fbf776f19898a9e7eacd76d0e244bdac /compiler/rustc_ty_utils/src | |
| parent | 6330c27ae24ec1556cf2b97eeac333dc23391686 (diff) | |
| download | rust-c97fd8183a98d6a89b8fc2e02eb068298e6fb7dc.tar.gz rust-c97fd8183a98d6a89b8fc2e02eb068298e6fb7dc.zip | |
Refactor tcx mk_const parameters.
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/consts.rs | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index e057bb66825..3cef47c0f8b 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -33,7 +33,7 @@ pub(crate) fn destructure_const<'tcx>( // construct the consts for the elements of the array/slice let field_consts = branches .iter() - .map(|b| tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Value(*b), ty: *inner_ty })) + .map(|b| tcx.mk_const(ty::ConstKind::Value(*b), *inner_ty)) .collect::<Vec<_>>(); debug!(?field_consts); @@ -52,10 +52,7 @@ pub(crate) fn destructure_const<'tcx>( for (field, field_valtree) in iter::zip(fields, branches) { let field_ty = field.ty(tcx, substs); - let field_const = tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Value(*field_valtree), - ty: field_ty, - }); + let field_const = tcx.mk_const(ty::ConstKind::Value(*field_valtree), field_ty); field_consts.push(field_const); } debug!(?field_consts); @@ -65,10 +62,7 @@ pub(crate) fn destructure_const<'tcx>( ty::Tuple(elem_tys) => { let fields = iter::zip(*elem_tys, branches) .map(|(elem_ty, elem_valtree)| { - tcx.mk_const(ty::ConstS { - kind: ty::ConstKind::Value(*elem_valtree), - ty: elem_ty, - }) + tcx.mk_const(ty::ConstKind::Value(*elem_valtree), elem_ty) }) .collect::<Vec<_>>(); @@ -261,17 +255,13 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { let uneval = ty::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs); - let constant = self - .tcx - .mk_const(ty::ConstS { kind: ty::ConstKind::Unevaluated(uneval), ty: node.ty }); + let constant = self.tcx.mk_const(ty::ConstKind::Unevaluated(uneval), node.ty); self.nodes.push(Node::Leaf(constant)) } ExprKind::ConstParam { param, .. } => { - let const_param = self - .tcx - .mk_const(ty::ConstS { kind: ty::ConstKind::Param(*param), ty: node.ty }); + let const_param = self.tcx.mk_const(ty::ConstKind::Param(*param), node.ty); self.nodes.push(Node::Leaf(const_param)) } |
