@@ -41,7 +41,6 @@ use ty::{self, TyCtxt, Instance};
4141use ty:: layout:: { self , Size } ;
4242use middle:: region;
4343use std:: io;
44- use std:: hash:: Hash ;
4544use rustc_serialize:: { Encoder , Decodable , Encodable } ;
4645use rustc_data_structures:: fx:: FxHashMap ;
4746use rustc_data_structures:: sync:: { Lock as Mutex , HashMapExt } ;
@@ -302,19 +301,19 @@ pub enum AllocType<'tcx, M> {
302301 Memory ( M )
303302}
304303
305- pub struct AllocMap < ' tcx , M > {
304+ pub struct AllocMap < ' tcx > {
306305 /// Lets you know what an AllocId refers to
307- id_to_type : FxHashMap < AllocId , AllocType < ' tcx , M > > ,
306+ id_to_type : FxHashMap < AllocId , AllocType < ' tcx , & ' tcx Allocation > > ,
308307
309308 /// Used to ensure that functions and statics only get one associated AllocId
310- type_interner : FxHashMap < AllocType < ' tcx , M > , AllocId > ,
309+ type_interner : FxHashMap < AllocType < ' tcx , & ' tcx Allocation > , AllocId > ,
311310
312311 /// The AllocId to assign to the next requested id.
313312 /// Always incremented, never gets smaller.
314313 next_id : AllocId ,
315314}
316315
317- impl < ' tcx , M : fmt :: Debug + Eq + Hash + Clone > AllocMap < ' tcx , M > {
316+ impl < ' tcx > AllocMap < ' tcx > {
318317 pub fn new ( ) -> Self {
319318 AllocMap {
320319 id_to_type : Default :: default ( ) ,
@@ -337,7 +336,7 @@ impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> {
337336 next
338337 }
339338
340- fn intern ( & mut self , alloc_type : AllocType < ' tcx , M > ) -> AllocId {
339+ fn intern ( & mut self , alloc_type : AllocType < ' tcx , & ' tcx Allocation > ) -> AllocId {
341340 if let Some ( & alloc_id) = self . type_interner . get ( & alloc_type) {
342341 return alloc_id;
343342 }
@@ -355,11 +354,11 @@ impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> {
355354 self . intern ( AllocType :: Function ( instance) )
356355 }
357356
358- pub fn get ( & self , id : AllocId ) -> Option < AllocType < ' tcx , M > > {
357+ pub fn get ( & self , id : AllocId ) -> Option < AllocType < ' tcx , & ' tcx Allocation > > {
359358 self . id_to_type . get ( & id) . cloned ( )
360359 }
361360
362- pub fn unwrap_memory ( & self , id : AllocId ) -> M {
361+ pub fn unwrap_memory ( & self , id : AllocId ) -> & ' tcx Allocation {
363362 match self . get ( id) {
364363 Some ( AllocType :: Memory ( mem) ) => mem,
365364 _ => bug ! ( "expected allocation id {} to point to memory" , id) ,
@@ -370,19 +369,19 @@ impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> {
370369 self . intern ( AllocType :: Static ( static_id) )
371370 }
372371
373- pub fn allocate ( & mut self , mem : M ) -> AllocId {
372+ pub fn allocate ( & mut self , mem : & ' tcx Allocation ) -> AllocId {
374373 let id = self . reserve ( ) ;
375374 self . set_id_memory ( id, mem) ;
376375 id
377376 }
378377
379- pub fn set_id_memory ( & mut self , id : AllocId , mem : M ) {
378+ pub fn set_id_memory ( & mut self , id : AllocId , mem : & ' tcx Allocation ) {
380379 if let Some ( old) = self . id_to_type . insert ( id, AllocType :: Memory ( mem) ) {
381380 bug ! ( "tried to set allocation id {}, but it was already existing as {:#?}" , id, old) ;
382381 }
383382 }
384383
385- pub fn set_id_same_memory ( & mut self , id : AllocId , mem : M ) {
384+ pub fn set_id_same_memory ( & mut self , id : AllocId , mem : & ' tcx Allocation ) {
386385 self . id_to_type . insert_same ( id, AllocType :: Memory ( mem) ) ;
387386 }
388387}
0 commit comments