diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-28 12:38:15 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-28 17:28:30 +0000 |
| commit | f4d00fe78550eac378594a9c0d0708a6c871f337 (patch) | |
| tree | 264e545c947dd8efed6735f62c951785ff9322bb /compiler/rustc_middle/src | |
| parent | 26b87bf8ff8406e80e70559b71cf0095475cc64a (diff) | |
Remove `Const::from_value`
...it's just `mk_const` but without the sparcles
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/consts.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 3 |
2 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index cd0b280ce4e..eaeb08c7aed 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -140,12 +140,6 @@ impl<'tcx> Const<'tcx> { } } - /// Interns the given value as a constant. - #[inline] - pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Self { - tcx.mk_const(val, ty) - } - /// Panics if self.kind != ty::ConstKind::Value pub fn to_valtree(self) -> ty::ValTree<'tcx> { match self.kind() { @@ -156,7 +150,7 @@ impl<'tcx> Const<'tcx> { pub fn from_scalar_int(tcx: TyCtxt<'tcx>, i: ScalarInt, ty: Ty<'tcx>) -> Self { let valtree = ty::ValTree::from_scalar_int(i); - Self::from_value(tcx, valtree, ty) + tcx.mk_const(valtree, ty) } #[inline] @@ -172,8 +166,7 @@ impl<'tcx> Const<'tcx> { #[inline] /// Creates an interned zst constant. pub fn zero_sized(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self { - let valtree = ty::ValTree::zst(); - Self::from_value(tcx, valtree, ty) + tcx.mk_const(ty::ValTree::zst(), ty) } #[inline] @@ -220,7 +213,7 @@ impl<'tcx> Const<'tcx> { pub fn eval(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Const<'tcx> { if let Some(val) = self.kind().try_eval_for_typeck(tcx, param_env) { match val { - Ok(val) => Const::from_value(tcx, val, self.ty()), + Ok(val) => tcx.mk_const(val, self.ty()), Err(guar) => tcx.const_error_with_guaranteed(self.ty(), guar), } } else { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index bd17f7d34ad..5303341ba44 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1468,8 +1468,7 @@ pub trait PrettyPrinter<'tcx>: } // Aggregates, printed as array/tuple/struct/variant construction syntax. (ty::ValTree::Branch(_), ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) => { - let contents = - self.tcx().destructure_const(ty::Const::from_value(self.tcx(), valtree, ty)); + let contents = self.tcx().destructure_const(self.tcx().mk_const(valtree, ty)); let fields = contents.fields.iter().copied(); match *ty.kind() { ty::Array(..) => { |
