@@ -22,7 +22,7 @@ use std::ptr;
2222
2323use rustc:: ty:: { self , Instance , query:: TyCtxtAt } ;
2424use 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 ,
2626 EvalResult , Scalar , EvalErrorKind , AllocType , PointerArithmetic ,
2727 truncate} ;
2828pub 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> {
340340 // no need to report anything, the const_eval call takes care of that for statics
341341 assert ! ( tcx. is_static( def_id) . is_some( ) ) ;
342342 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+ }
346349 } )
347350 }
348351
0 commit comments