@@ -5,7 +5,7 @@ use crate::const_eval::CanAccessStatics;
55use crate :: interpret:: MPlaceTy ;
66use crate :: interpret:: {
77 intern_const_alloc_recursive, ConstValue , ImmTy , Immediate , InternKind , MemPlaceMeta ,
8- MemoryKind , PlaceTy , Projectable , Scalar ,
8+ MemoryKind , Place , Projectable , Scalar ,
99} ;
1010use rustc_middle:: ty:: { self , ScalarInt , Ty , TyCtxt } ;
1111use rustc_span:: source_map:: DUMMY_SP ;
@@ -21,7 +21,7 @@ fn branches<'tcx>(
2121) -> ValTreeCreationResult < ' tcx > {
2222 let place = match variant {
2323 Some ( variant) => ecx. project_downcast ( place, variant) . unwrap ( ) ,
24- None => * place,
24+ None => place. clone ( ) ,
2525 } ;
2626 let variant = variant. map ( |variant| Some ( ty:: ValTree :: Leaf ( ScalarInt :: from ( variant. as_u32 ( ) ) ) ) ) ;
2727 debug ! ( ?place, ?variant) ;
@@ -86,7 +86,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
8686 Ok ( ty:: ValTree :: zst ( ) )
8787 }
8888 ty:: Bool | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Char => {
89- let Ok ( val) = ecx. read_immediate ( & place. into ( ) ) else {
89+ let Ok ( val) = ecx. read_immediate ( place) else {
9090 return Err ( ValTreeCreationError :: Other ) ;
9191 } ;
9292 let val = val. to_scalar ( ) ;
@@ -102,7 +102,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
102102 ty:: FnPtr ( _) | ty:: RawPtr ( _) => Err ( ValTreeCreationError :: NonSupportedType ) ,
103103
104104 ty:: Ref ( _, _, _) => {
105- let Ok ( derefd_place) = ecx. deref_operand ( & place. into ( ) ) else {
105+ let Ok ( derefd_place) = ecx. deref_operand ( place) else {
106106 return Err ( ValTreeCreationError :: Other ) ;
107107 } ;
108108 debug ! ( ?derefd_place) ;
@@ -130,7 +130,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
130130 bug ! ( "uninhabited types should have errored and never gotten converted to valtree" )
131131 }
132132
133- let Ok ( variant) = ecx. read_discriminant ( & place. into ( ) ) else {
133+ let Ok ( variant) = ecx. read_discriminant ( place) else {
134134 return Err ( ValTreeCreationError :: Other ) ;
135135 } ;
136136 branches ( ecx, place, def. variant ( variant) . fields . len ( ) , def. is_enum ( ) . then_some ( variant) , num_nodes)
@@ -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. 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" ) ]
330330fn 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
@@ -345,14 +345,14 @@ fn valtree_into_mplace<'tcx>(
345345 ty:: Bool | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Char => {
346346 let scalar_int = valtree. unwrap_leaf ( ) ;
347347 debug ! ( "writing trivial valtree {:?} to place {:?}" , scalar_int, place) ;
348- ecx. write_immediate ( Immediate :: Scalar ( scalar_int. into ( ) ) , & place. into ( ) ) . unwrap ( ) ;
348+ 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. 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 ( ) {
@@ -369,7 +369,7 @@ fn valtree_into_mplace<'tcx>(
369369 } ;
370370 debug ! ( ?imm) ;
371371
372- ecx. write_immediate ( imm, & place. into ( ) ) . unwrap ( ) ;
372+ ecx. write_immediate ( imm, place) . unwrap ( ) ;
373373 }
374374 ty:: Adt ( _, _) | ty:: Tuple ( _) | ty:: Array ( _, _) | ty:: Str | ty:: Slice ( _) => {
375375 let branches = valtree. unwrap_branch ( ) ;
@@ -389,7 +389,7 @@ fn valtree_into_mplace<'tcx>(
389389 Some ( variant_idx) ,
390390 )
391391 }
392- _ => ( * place, branches, None ) ,
392+ _ => ( place. clone ( ) , branches, None ) ,
393393 } ;
394394 debug ! ( ?place_adjusted, ?branches) ;
395395
@@ -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
455- ecx. write_discriminant ( variant_idx, & place. into ( ) ) . unwrap ( ) ;
455+ ecx. write_discriminant ( variant_idx, place) . unwrap ( ) ;
456456 }
457457
458458 debug ! ( "dump of place after writing discriminant:" ) ;
459- dump_place ( ecx, place. 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