55use rustc_hir:: def_id:: DefId ;
66use rustc_middle:: mir:: {
77 self ,
8- interpret:: { Allocation , ConstAllocation , GlobalId , InterpResult , PointerArithmetic , Scalar } ,
8+ interpret:: { AllocId , GlobalId , InterpResult , PointerArithmetic , Scalar } ,
99 BinOp , ConstValue , NonDivergingIntrinsic ,
1010} ;
1111use rustc_middle:: ty;
@@ -42,10 +42,11 @@ fn numeric_intrinsic<Prov>(name: Symbol, bits: u128, kind: Primitive) -> Scalar<
4242}
4343
4444/// Directly returns an `Allocation` containing an absolute path representation of the given type.
45- pub ( crate ) fn alloc_type_name < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ConstAllocation < ' tcx > {
45+ pub ( crate ) fn alloc_type_name < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ( AllocId , u64 ) {
4646 let path = crate :: util:: type_name ( tcx, ty) ;
47- let alloc = Allocation :: from_bytes_byte_aligned_immutable ( path. into_bytes ( ) ) ;
48- tcx. mk_const_alloc ( alloc)
47+ let bytes = path. into_bytes ( ) ;
48+ let len = bytes. len ( ) . try_into ( ) . unwrap ( ) ;
49+ ( tcx. allocate_bytes ( bytes) , len)
4950}
5051
5152/// The logic for all nullary intrinsics is implemented here. These intrinsics don't get evaluated
@@ -55,14 +56,14 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
5556 param_env : ty:: ParamEnv < ' tcx > ,
5657 def_id : DefId ,
5758 args : GenericArgsRef < ' tcx > ,
58- ) -> InterpResult < ' tcx , ConstValue < ' tcx > > {
59+ ) -> InterpResult < ' tcx , ConstValue > {
5960 let tp_ty = args. type_at ( 0 ) ;
6061 let name = tcx. item_name ( def_id) ;
6162 Ok ( match name {
6263 sym:: type_name => {
6364 ensure_monomorphic_enough ( tcx, tp_ty) ?;
64- let alloc = alloc_type_name ( tcx, tp_ty) ;
65- ConstValue :: Slice { data : alloc , meta : alloc . inner ( ) . size ( ) . bytes ( ) }
65+ let ( alloc_id , len ) = alloc_type_name ( tcx, tp_ty) ;
66+ ConstValue :: Slice { alloc_id , meta : len }
6667 }
6768 sym:: needs_drop => {
6869 ensure_monomorphic_enough ( tcx, tp_ty) ?;
0 commit comments