@@ -447,14 +447,14 @@ impl<'tcx> TyCtxt<'tcx> {
447
447
///
448
448
/// Make sure to call `set_alloc_id_memory` or `set_alloc_id_same_memory` before returning such
449
449
/// an `AllocId` from a query.
450
- pub fn reserve_alloc_id ( & self ) -> AllocId {
450
+ pub fn reserve_alloc_id ( self ) -> AllocId {
451
451
self . alloc_map . lock ( ) . reserve ( )
452
452
}
453
453
454
454
/// Reserves a new ID *if* this allocation has not been dedup-reserved before.
455
455
/// Should only be used for function pointers and statics, we don't want
456
456
/// to dedup IDs for "real" memory!
457
- fn reserve_and_set_dedup ( & self , alloc : GlobalAlloc < ' tcx > ) -> AllocId {
457
+ fn reserve_and_set_dedup ( self , alloc : GlobalAlloc < ' tcx > ) -> AllocId {
458
458
let mut alloc_map = self . alloc_map . lock ( ) ;
459
459
match alloc {
460
460
GlobalAlloc :: Function ( ..) | GlobalAlloc :: Static ( ..) => { }
@@ -472,13 +472,13 @@ impl<'tcx> TyCtxt<'tcx> {
472
472
473
473
/// Generates an `AllocId` for a static or return a cached one in case this function has been
474
474
/// called on the same static before.
475
- pub fn create_static_alloc ( & self , static_id : DefId ) -> AllocId {
475
+ pub fn create_static_alloc ( self , static_id : DefId ) -> AllocId {
476
476
self . reserve_and_set_dedup ( GlobalAlloc :: Static ( static_id) )
477
477
}
478
478
479
479
/// Generates an `AllocId` for a function. Depending on the function type,
480
480
/// this might get deduplicated or assigned a new ID each time.
481
- pub fn create_fn_alloc ( & self , instance : Instance < ' tcx > ) -> AllocId {
481
+ pub fn create_fn_alloc ( self , instance : Instance < ' tcx > ) -> AllocId {
482
482
// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
483
483
// by the linker (we set the "unnamed_addr" attribute for LLVM) and functions can be
484
484
// duplicated across crates.
@@ -507,7 +507,7 @@ impl<'tcx> TyCtxt<'tcx> {
507
507
/// Statics with identical content will still point to the same `Allocation`, i.e.,
508
508
/// their data will be deduplicated through `Allocation` interning -- but they
509
509
/// are different places in memory and as such need different IDs.
510
- pub fn create_memory_alloc ( & self , mem : & ' tcx Allocation ) -> AllocId {
510
+ pub fn create_memory_alloc ( self , mem : & ' tcx Allocation ) -> AllocId {
511
511
let id = self . reserve_alloc_id ( ) ;
512
512
self . set_alloc_id_memory ( id, mem) ;
513
513
id
@@ -519,7 +519,7 @@ impl<'tcx> TyCtxt<'tcx> {
519
519
/// This function exists to allow const eval to detect the difference between evaluation-
520
520
/// local dangling pointers and allocations in constants/statics.
521
521
#[ inline]
522
- pub fn get_global_alloc ( & self , id : AllocId ) -> Option < GlobalAlloc < ' tcx > > {
522
+ pub fn get_global_alloc ( self , id : AllocId ) -> Option < GlobalAlloc < ' tcx > > {
523
523
self . alloc_map . lock ( ) . alloc_map . get ( & id) . cloned ( )
524
524
}
525
525
@@ -529,7 +529,7 @@ impl<'tcx> TyCtxt<'tcx> {
529
529
/// constants (as all constants must pass interning and validation that check for dangling
530
530
/// ids), this function is frequently used throughout rustc, but should not be used within
531
531
/// the miri engine.
532
- pub fn global_alloc ( & self , id : AllocId ) -> GlobalAlloc < ' tcx > {
532
+ pub fn global_alloc ( self , id : AllocId ) -> GlobalAlloc < ' tcx > {
533
533
match self . get_global_alloc ( id) {
534
534
Some ( alloc) => alloc,
535
535
None => bug ! ( "could not find allocation for {}" , id) ,
@@ -538,15 +538,15 @@ impl<'tcx> TyCtxt<'tcx> {
538
538
539
539
/// Freezes an `AllocId` created with `reserve` by pointing it at an `Allocation`. Trying to
540
540
/// call this function twice, even with the same `Allocation` will ICE the compiler.
541
- pub fn set_alloc_id_memory ( & self , id : AllocId , mem : & ' tcx Allocation ) {
541
+ pub fn set_alloc_id_memory ( self , id : AllocId , mem : & ' tcx Allocation ) {
542
542
if let Some ( old) = self . alloc_map . lock ( ) . alloc_map . insert ( id, GlobalAlloc :: Memory ( mem) ) {
543
543
bug ! ( "tried to set allocation ID {}, but it was already existing as {:#?}" , id, old) ;
544
544
}
545
545
}
546
546
547
547
/// Freezes an `AllocId` created with `reserve` by pointing it at an `Allocation`. May be called
548
548
/// twice for the same `(AllocId, Allocation)` pair.
549
- fn set_alloc_id_same_memory ( & self , id : AllocId , mem : & ' tcx Allocation ) {
549
+ fn set_alloc_id_same_memory ( self , id : AllocId , mem : & ' tcx Allocation ) {
550
550
self . alloc_map . lock ( ) . alloc_map . insert_same ( id, GlobalAlloc :: Memory ( mem) ) ;
551
551
}
552
552
}
0 commit comments