@@ -512,13 +512,22 @@ mod stack {
512
512
use super :: super :: node:: handle;
513
513
use vec:: Vec ;
514
514
515
+ struct InvariantLifetime < ' id > (
516
+ marker:: PhantomData < :: core:: cell:: Cell < & ' id ( ) > > ) ;
517
+
518
+ impl < ' id > InvariantLifetime < ' id > {
519
+ fn new ( ) -> InvariantLifetime < ' id > {
520
+ InvariantLifetime ( marker:: PhantomData )
521
+ }
522
+ }
523
+
515
524
/// A generic mutable reference, identical to `&mut` except for the fact that its lifetime
516
525
/// parameter is invariant. This means that wherever an `IdRef` is expected, only an `IdRef`
517
526
/// with the exact requested lifetime can be used. This is in contrast to normal references,
518
527
/// where `&'static` can be used in any function expecting any lifetime reference.
519
528
pub struct IdRef < ' id , T : ' id > {
520
529
inner : & ' id mut T ,
521
- marker : marker :: InvariantLifetime < ' id >
530
+ _marker : InvariantLifetime < ' id > ,
522
531
}
523
532
524
533
impl < ' id , T > Deref for IdRef < ' id , T > {
@@ -560,7 +569,7 @@ mod stack {
560
569
pub struct Pusher < ' id , ' a , K : ' a , V : ' a > {
561
570
map : & ' a mut BTreeMap < K , V > ,
562
571
stack : Stack < K , V > ,
563
- marker : marker :: InvariantLifetime < ' id >
572
+ _marker : InvariantLifetime < ' id > ,
564
573
}
565
574
566
575
impl < ' a , K , V > PartialSearchStack < ' a , K , V > {
@@ -595,11 +604,11 @@ mod stack {
595
604
let pusher = Pusher {
596
605
map : self . map ,
597
606
stack : self . stack ,
598
- marker : marker :: InvariantLifetime
607
+ _marker : InvariantLifetime :: new ( ) ,
599
608
} ;
600
609
let node = IdRef {
601
610
inner : unsafe { & mut * self . next } ,
602
- marker : marker :: InvariantLifetime
611
+ _marker : InvariantLifetime :: new ( ) ,
603
612
} ;
604
613
605
614
closure ( pusher, node)
0 commit comments