5
5
use rustc_hir:: def_id:: DefId ;
6
6
use rustc_middle:: mir:: {
7
7
self ,
8
- interpret:: { Allocation , ConstAllocation , GlobalId , InterpResult , PointerArithmetic , Scalar } ,
8
+ interpret:: { AllocId , GlobalId , InterpResult , PointerArithmetic , Scalar } ,
9
9
BinOp , ConstValue , NonDivergingIntrinsic ,
10
10
} ;
11
11
use rustc_middle:: ty;
@@ -42,10 +42,11 @@ fn numeric_intrinsic<Prov>(name: Symbol, bits: u128, kind: Primitive) -> Scalar<
42
42
}
43
43
44
44
/// 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 ) {
46
46
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)
49
50
}
50
51
51
52
/// 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>(
55
56
param_env : ty:: ParamEnv < ' tcx > ,
56
57
def_id : DefId ,
57
58
args : GenericArgsRef < ' tcx > ,
58
- ) -> InterpResult < ' tcx , ConstValue < ' tcx > > {
59
+ ) -> InterpResult < ' tcx , ConstValue > {
59
60
let tp_ty = args. type_at ( 0 ) ;
60
61
let name = tcx. item_name ( def_id) ;
61
62
Ok ( match name {
62
63
sym:: type_name => {
63
64
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 }
66
67
}
67
68
sym:: needs_drop => {
68
69
ensure_monomorphic_enough ( tcx, tp_ty) ?;
0 commit comments