@@ -2868,16 +2868,10 @@ mod ref_mut {
28682868 #[ track_caller]
28692869 pub ( crate ) fn get_mut ( & mut self ) -> & mut T {
28702870 match self . mutable {
2871- false => panic ! ( "Can 't mutably borrow speculative resolver" ) ,
2871+ false => panic ! ( "can 't mutably borrow speculative resolver" ) ,
28722872 true => self . p ,
28732873 }
28742874 }
2875-
2876- /// Returns a mutable reference to the inner value without checking if
2877- /// it's in a mutable state.
2878- pub ( crate ) fn get_mut_unchecked ( & mut self ) -> & mut T {
2879- self . p
2880- }
28812875 }
28822876
28832877 /// A wrapper around a [`Cell`] that only allows mutation based on a condition in the resolver.
@@ -2901,12 +2895,12 @@ mod ref_mut {
29012895 self . 0 . get ( )
29022896 }
29032897
2904- pub ( crate ) fn update_unchecked ( & self , f : impl FnOnce ( T ) -> T )
2898+ pub ( crate ) fn update < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > , f : impl FnOnce ( T ) -> T )
29052899 where
29062900 T : Copy ,
29072901 {
29082902 let old = self . get ( ) ;
2909- self . set_unchecked ( f ( old) ) ;
2903+ self . set ( f ( old) , r ) ;
29102904 }
29112905 }
29122906
@@ -2915,7 +2909,10 @@ mod ref_mut {
29152909 CmCell ( Cell :: new ( value) )
29162910 }
29172911
2918- pub ( crate ) fn set_unchecked ( & self , val : T ) {
2912+ pub ( crate ) fn set < ' ra , ' tcx > ( & self , val : T , r : & Resolver < ' ra , ' tcx > ) {
2913+ if r. assert_speculative {
2914+ panic ! ( "not allowed to mutate a `CmCell` during speculative resolution" )
2915+ }
29192916 self . 0 . set ( val) ;
29202917 }
29212918
@@ -2941,16 +2938,26 @@ mod ref_mut {
29412938 #[ track_caller]
29422939 pub ( crate ) fn borrow_mut < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > ) -> RefMut < ' _ , T > {
29432940 if r. assert_speculative {
2944- panic ! ( "Not allowed to mutably borrow a CmRefCell during speculative resolution" ) ;
2941+ panic ! ( "not allowed to mutably borrow a ` CmRefCell` during speculative resolution" ) ;
29452942 }
2946- self . borrow_mut_unchecked ( )
2943+ self . 0 . borrow_mut ( )
29472944 }
29482945
2949- #[ track_caller]
29502946 pub ( crate ) fn try_borrow_mut_unchecked ( & self ) -> Result < RefMut < ' _ , T > , BorrowMutError > {
29512947 self . 0 . try_borrow_mut ( )
29522948 }
29532949
2950+ #[ track_caller]
2951+ pub ( crate ) fn try_borrow_mut < ' ra , ' tcx > (
2952+ & self ,
2953+ r : & Resolver < ' ra , ' tcx > ,
2954+ ) -> Result < RefMut < ' _ , T > , BorrowMutError > {
2955+ if r. assert_speculative {
2956+ panic ! ( "not allowed to mutably borrow a `CmRefCell` during speculative resolution" ) ;
2957+ }
2958+ self . 0 . try_borrow_mut ( )
2959+ }
2960+
29542961 #[ track_caller]
29552962 pub ( crate ) fn borrow ( & self ) -> Ref < ' _ , T > {
29562963 self . 0 . borrow ( )
@@ -2960,7 +2967,7 @@ mod ref_mut {
29602967 impl < T : Default > CmRefCell < T > {
29612968 pub ( crate ) fn take < ' ra , ' tcx > ( & self , r : & Resolver < ' ra , ' tcx > ) -> T {
29622969 if r. assert_speculative {
2963- panic ! ( "Not allowed to mutate a CmRefCell during speculative resolution" ) ;
2970+ panic ! ( "not allowed to mutate a CmRefCell during speculative resolution" ) ;
29642971 }
29652972 self . 0 . take ( )
29662973 }
0 commit comments