Skip to content

Commit 571e8ce

Browse files
committed
valtree: a bit of cleanup
1 parent da3f0d0 commit 571e8ce

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::const_eval::CanAccessStatics;
55
use crate::interpret::MPlaceTy;
66
use crate::interpret::{
77
intern_const_alloc_recursive, ConstValue, ImmTy, Immediate, InternKind, MemPlaceMeta,
8-
MemoryKind, PlaceTy, Projectable, Scalar,
8+
MemoryKind, Place, Projectable, Scalar,
99
};
1010
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt};
1111
use rustc_span::source_map::DUMMY_SP;
@@ -280,7 +280,7 @@ pub fn valtree_to_const_value<'tcx>(
280280
),
281281
},
282282
ty::Ref(_, _, _) | ty::Tuple(_) | ty::Array(_, _) | ty::Adt(..) => {
283-
let mut place = match ty.kind() {
283+
let place = match ty.kind() {
284284
ty::Ref(_, inner_ty, _) => {
285285
// Need to create a place for the pointee to fill for Refs
286286
create_pointee_place(&mut ecx, *inner_ty, valtree)
@@ -289,8 +289,8 @@ pub fn valtree_to_const_value<'tcx>(
289289
};
290290
debug!(?place);
291291

292-
valtree_into_mplace(&mut ecx, &mut place, valtree);
293-
dump_place(&ecx, place.clone().into());
292+
valtree_into_mplace(&mut ecx, &place, valtree);
293+
dump_place(&ecx, &place);
294294
intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &place).unwrap();
295295

296296
match ty.kind() {
@@ -329,7 +329,7 @@ pub fn valtree_to_const_value<'tcx>(
329329
#[instrument(skip(ecx), level = "debug")]
330330
fn valtree_into_mplace<'tcx>(
331331
ecx: &mut CompileTimeEvalContext<'tcx, 'tcx>,
332-
place: &mut MPlaceTy<'tcx>,
332+
place: &MPlaceTy<'tcx>,
333333
valtree: ty::ValTree<'tcx>,
334334
) {
335335
// This will match on valtree and write the value(s) corresponding to the ValTree
@@ -348,11 +348,11 @@ fn valtree_into_mplace<'tcx>(
348348
ecx.write_immediate(Immediate::Scalar(scalar_int.into()), place).unwrap();
349349
}
350350
ty::Ref(_, inner_ty, _) => {
351-
let mut pointee_place = create_pointee_place(ecx, *inner_ty, valtree);
351+
let pointee_place = create_pointee_place(ecx, *inner_ty, valtree);
352352
debug!(?pointee_place);
353353

354-
valtree_into_mplace(ecx, &mut pointee_place, valtree);
355-
dump_place(ecx, pointee_place.clone().into());
354+
valtree_into_mplace(ecx, &pointee_place, valtree);
355+
dump_place(ecx, &pointee_place);
356356
intern_const_alloc_recursive(ecx, InternKind::Constant, &pointee_place).unwrap();
357357

358358
let imm = match inner_ty.kind() {
@@ -398,7 +398,7 @@ fn valtree_into_mplace<'tcx>(
398398
for (i, inner_valtree) in branches.iter().enumerate() {
399399
debug!(?i, ?inner_valtree);
400400

401-
let mut place_inner = match ty.kind() {
401+
let place_inner = match ty.kind() {
402402
ty::Str | ty::Slice(_) => ecx.project_index(place, i as u64).unwrap(),
403403
_ if !ty.is_sized(*ecx.tcx, ty::ParamEnv::empty())
404404
&& i == branches.len() - 1 =>
@@ -443,25 +443,25 @@ fn valtree_into_mplace<'tcx>(
443443
};
444444

445445
debug!(?place_inner);
446-
valtree_into_mplace(ecx, &mut place_inner, *inner_valtree);
447-
dump_place(&ecx, place_inner.into());
446+
valtree_into_mplace(ecx, &place_inner, *inner_valtree);
447+
dump_place(&ecx, &place_inner);
448448
}
449449

450450
debug!("dump of place_adjusted:");
451-
dump_place(ecx, place_adjusted.into());
451+
dump_place(ecx, &place_adjusted);
452452

453453
if let Some(variant_idx) = variant_idx {
454454
// don't forget filling the place with the discriminant of the enum
455455
ecx.write_discriminant(variant_idx, place).unwrap();
456456
}
457457

458458
debug!("dump of place after writing discriminant:");
459-
dump_place(ecx, place.clone().into());
459+
dump_place(ecx, place);
460460
}
461461
_ => bug!("shouldn't have created a ValTree for {:?}", ty),
462462
}
463463
}
464464

465-
fn dump_place<'tcx>(ecx: &CompileTimeEvalContext<'tcx, 'tcx>, place: PlaceTy<'tcx>) {
466-
trace!("{:?}", ecx.dump_place(*place));
465+
fn dump_place<'tcx>(ecx: &CompileTimeEvalContext<'tcx, 'tcx>, place: &MPlaceTy<'tcx>) {
466+
trace!("{:?}", ecx.dump_place(Place::Ptr(**place)));
467467
}

0 commit comments

Comments
 (0)