@@ -22,7 +22,7 @@ use std::ptr;
22
22
23
23
use rustc:: ty:: { self , Instance , query:: TyCtxtAt } ;
24
24
use rustc:: ty:: layout:: { self , Align , TargetDataLayout , Size , HasDataLayout } ;
25
- use rustc:: mir:: interpret:: { Pointer , AllocId , Allocation , ScalarMaybeUndef , GlobalId ,
25
+ use rustc:: mir:: interpret:: { Pointer , AllocId , Allocation , ConstValue , ScalarMaybeUndef , GlobalId ,
26
26
EvalResult , Scalar , EvalErrorKind , AllocType , PointerArithmetic ,
27
27
truncate} ;
28
28
pub use rustc:: mir:: interpret:: { write_target_uint, read_target_uint} ;
@@ -340,9 +340,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
340
340
// no need to report anything, the const_eval call takes care of that for statics
341
341
assert ! ( tcx. is_static( def_id) . is_some( ) ) ;
342
342
EvalErrorKind :: ReferencedConstant ( err) . into ( )
343
- } ) . map ( |val| {
344
- // FIXME We got our static (will be a ByRef), now we make a *copy*?!?
345
- tcx. const_to_allocation ( val)
343
+ } ) . map ( |const_val| {
344
+ if let ConstValue :: ByRef ( _, allocation, _) = const_val. val {
345
+ allocation
346
+ } else {
347
+ bug ! ( "Matching on non-ByRef static" )
348
+ }
346
349
} )
347
350
}
348
351
0 commit comments