diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2021-03-10 11:45:22 +0000 |
|---|---|---|
| committer | Oli Scherer <github35764891676564198441@oli-obk.de> | 2021-03-12 12:44:12 +0000 |
| commit | 20f737966ec350e3cdc3b4193f2d000ad321d10e (patch) | |
| tree | b7f0b7b25e8a33ed72aa95bf2d60346be1c35b03 | |
| parent | 3127a9c60f267c862d2b0f1250c28f38891b94aa (diff) | |
| download | rust-20f737966ec350e3cdc3b4193f2d000ad321d10e.tar.gz rust-20f737966ec350e3cdc3b4193f2d000ad321d10e.zip | |
Replace a custom lift method with a Lift impl
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/value.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index cddcc7d576a..515aabd59bc 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -8,7 +8,7 @@ use rustc_apfloat::{ use rustc_macros::HashStable; use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; -use crate::ty::{ParamEnv, ScalarInt, Ty, TyCtxt}; +use crate::ty::{Lift, ParamEnv, ScalarInt, Ty, TyCtxt}; use super::{AllocId, Allocation, InterpResult, Pointer, PointerArithmetic}; @@ -53,8 +53,9 @@ impl From<Scalar> for ConstValue<'tcx> { } } -impl<'tcx> ConstValue<'tcx> { - pub fn lift<'lifted>(self, tcx: TyCtxt<'lifted>) -> Option<ConstValue<'lifted>> { +impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> { + type Lifted = ConstValue<'tcx>; + fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ConstValue<'tcx>> { Some(match self { ConstValue::Scalar(s) => ConstValue::Scalar(s), ConstValue::Slice { data, start, end } => { @@ -65,7 +66,9 @@ impl<'tcx> ConstValue<'tcx> { } }) } +} +impl<'tcx> ConstValue<'tcx> { #[inline] pub fn try_to_scalar(&self) -> Option<Scalar> { match *self { diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 20ba82a8e86..481d02fccf5 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2738,7 +2738,7 @@ fn pretty_print_const_value( ) -> fmt::Result { use crate::ty::print::PrettyPrinter; ty::tls::with(|tcx| { - let val = val.lift(tcx).unwrap(); + let val = tcx.lift(val).unwrap(); let ty = tcx.lift(ty).unwrap(); let mut cx = FmtPrinter::new(tcx, fmt, Namespace::ValueNS); cx.print_alloc_ids = true; |
