@@ -2652,16 +2652,10 @@ mod ref_mut {
26522652 #[ track_caller]
26532653 pub ( crate ) fn get_mut ( & mut self ) -> & mut T {
26542654 match self . mutable {
2655- false => panic ! ( "Can 't mutably borrow speculative resolver" ) ,
2655+ false => panic ! ( "can 't mutably borrow speculative resolver" ) ,
26562656 true => self . p ,
26572657 }
26582658 }
2659-
2660- /// Returns a mutable reference to the inner value without checking if
2661- /// it's in a mutable state.
2662- pub ( crate ) fn get_mut_unchecked ( & mut self ) -> & mut T {
2663- self . p
2664- }
26652659 }
26662660
26672661 /// A wrapper around a [`Cell`] that only allows mutation based on a condition in the resolver.
@@ -2685,12 +2679,12 @@ mod ref_mut {
26852679 self . 0 . get ( )
26862680 }
26872681
2688- pub ( crate ) fn update_unchecked ( & self , f : impl FnOnce ( T ) -> T )
2682+ pub ( crate ) fn update < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > , f : impl FnOnce ( T ) -> T )
26892683 where
26902684 T : Copy ,
26912685 {
26922686 let old = self . get ( ) ;
2693- self . set_unchecked ( f ( old) ) ;
2687+ self . set ( f ( old) , r ) ;
26942688 }
26952689 }
26962690
@@ -2699,7 +2693,10 @@ mod ref_mut {
26992693 CmCell ( Cell :: new ( value) )
27002694 }
27012695
2702- pub ( crate ) fn set_unchecked ( & self , val : T ) {
2696+ pub ( crate ) fn set < ' ra , ' tcx > ( & self , val : T , r : & Resolver < ' ra , ' tcx > ) {
2697+ if r. assert_speculative {
2698+ panic ! ( "not allowed to mutate a `CmCell` during speculative resolution" )
2699+ }
27032700 self . 0 . set ( val) ;
27042701 }
27052702
@@ -2725,16 +2722,26 @@ mod ref_mut {
27252722 #[ track_caller]
27262723 pub ( crate ) fn borrow_mut < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > ) -> RefMut < ' _ , T > {
27272724 if r. assert_speculative {
2728- panic ! ( "Not allowed to mutably borrow a CmRefCell during speculative resolution" ) ;
2725+ panic ! ( "not allowed to mutably borrow a ` CmRefCell` during speculative resolution" ) ;
27292726 }
2730- self . borrow_mut_unchecked ( )
2727+ self . 0 . borrow_mut ( )
27312728 }
27322729
2733- #[ track_caller]
27342730 pub ( crate ) fn try_borrow_mut_unchecked ( & self ) -> Result < RefMut < ' _ , T > , BorrowMutError > {
27352731 self . 0 . try_borrow_mut ( )
27362732 }
27372733
2734+ #[ track_caller]
2735+ pub ( crate ) fn try_borrow_mut < ' ra , ' tcx > (
2736+ & self ,
2737+ r : & Resolver < ' ra , ' tcx > ,
2738+ ) -> Result < RefMut < ' _ , T > , BorrowMutError > {
2739+ if r. assert_speculative {
2740+ panic ! ( "not allowed to mutably borrow a `CmRefCell` during speculative resolution" ) ;
2741+ }
2742+ self . 0 . try_borrow_mut ( )
2743+ }
2744+
27382745 #[ track_caller]
27392746 pub ( crate ) fn borrow ( & self ) -> Ref < ' _ , T > {
27402747 self . 0 . borrow ( )
@@ -2744,7 +2751,7 @@ mod ref_mut {
27442751 impl < T : Default > CmRefCell < T > {
27452752 pub ( crate ) fn take < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > ) -> T {
27462753 if r. assert_speculative {
2747- panic ! ( "Not allowed to mutate a CmRefCell during speculative resolution" ) ;
2754+ panic ! ( "not allowed to mutate a CmRefCell during speculative resolution" ) ;
27482755 }
27492756 self . 0 . take ( )
27502757 }
0 commit comments