Skip to content

Commit 20f7379

Browse files
committed
Replace a custom lift method with a Lift impl
1 parent 3127a9c commit 20f7379

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

compiler/rustc_middle/src/mir/interpret/value.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_apfloat::{
88
use rustc_macros::HashStable;
99
use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout};
1010

11-
use crate::ty::{ParamEnv, ScalarInt, Ty, TyCtxt};
11+
use crate::ty::{Lift, ParamEnv, ScalarInt, Ty, TyCtxt};
1212

1313
use super::{AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
1414

@@ -53,8 +53,9 @@ impl From<Scalar> for ConstValue<'tcx> {
5353
}
5454
}
5555

56-
impl<'tcx> ConstValue<'tcx> {
57-
pub fn lift<'lifted>(self, tcx: TyCtxt<'lifted>) -> Option<ConstValue<'lifted>> {
56+
impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
57+
type Lifted = ConstValue<'tcx>;
58+
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ConstValue<'tcx>> {
5859
Some(match self {
5960
ConstValue::Scalar(s) => ConstValue::Scalar(s),
6061
ConstValue::Slice { data, start, end } => {
@@ -65,7 +66,9 @@ impl<'tcx> ConstValue<'tcx> {
6566
}
6667
})
6768
}
69+
}
6870

71+
impl<'tcx> ConstValue<'tcx> {
6972
#[inline]
7073
pub fn try_to_scalar(&self) -> Option<Scalar> {
7174
match *self {

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ fn pretty_print_const_value(
27382738
) -> fmt::Result {
27392739
use crate::ty::print::PrettyPrinter;
27402740
ty::tls::with(|tcx| {
2741-
let val = val.lift(tcx).unwrap();
2741+
let val = tcx.lift(val).unwrap();
27422742
let ty = tcx.lift(ty).unwrap();
27432743
let mut cx = FmtPrinter::new(tcx, fmt, Namespace::ValueNS);
27442744
cx.print_alloc_ids = true;

0 commit comments

Comments
 (0)