@@ -160,41 +160,41 @@ impl AccountInfo {
160160 ///
161161 /// # Safety
162162 ///
163- /// This does not check or modify the 4-bit refcell. Useful when instruction
164- /// has verified non-duplicate accounts.
165- pub unsafe fn unchecked_borrow_lamports ( & self ) -> & u64 {
163+ /// This method is unsafe because it does not return a `Ref`, thus leaving the borrow
164+ /// flag untouched. Useful when an instruction has verified non-duplicate accounts.
165+ pub unsafe fn borrow_lamports_unchecked ( & self ) -> & u64 {
166166 & ( * self . raw ) . lamports
167167 }
168168
169169 /// Returns a mutable reference to the lamports in the account.
170170 ///
171171 /// # Safety
172172 ///
173- /// This does not check or modify the 4-bit refcell. Useful when instruction
174- /// has verified non-duplicate accounts.
173+ /// This method is unsafe because it does not return a `Ref`, thus leaving the borrow
174+ /// flag untouched. Useful when an instruction has verified non-duplicate accounts.
175175 #[ allow( clippy:: mut_from_ref) ]
176- pub unsafe fn unchecked_borrow_mut_lamports ( & self ) -> & mut u64 {
176+ pub unsafe fn borrow_mut_lamports_unchecked ( & self ) -> & mut u64 {
177177 & mut ( * self . raw ) . lamports
178178 }
179179
180180 /// Returns a read-only reference to the data in the account.
181181 ///
182182 /// # Safety
183183 ///
184- /// This does not check or modify the 4-bit refcell. Useful when instruction
185- /// has verified non-duplicate accounts.
186- pub unsafe fn unchecked_borrow_data ( & self ) -> & [ u8 ] {
184+ /// This method is unsafe because it does not return a `Ref`, thus leaving the borrow
185+ /// flag untouched. Useful when an instruction has verified non-duplicate accounts.
186+ pub unsafe fn borrow_data_unchecked ( & self ) -> & [ u8 ] {
187187 core:: slice:: from_raw_parts ( self . data_ptr ( ) , self . data_len ( ) )
188188 }
189189
190190 /// Returns a mutable reference to the data in the account.
191191 ///
192192 /// # Safety
193193 ///
194- /// This does not check or modify the 4-bit refcell. Useful when instruction
195- /// has verified non-duplicate accounts.
194+ /// This method is unsafe because it does not return a `Ref`, thus leaving the borrow
195+ /// flag untouched. Useful when an instruction has verified non-duplicate accounts.
196196 #[ allow( clippy:: mut_from_ref) ]
197- pub unsafe fn unchecked_borrow_mut_data ( & self ) -> & mut [ u8 ] {
197+ pub unsafe fn borrow_mut_data_unchecked ( & self ) -> & mut [ u8 ] {
198198 core:: slice:: from_raw_parts_mut ( self . data_ptr ( ) , self . data_len ( ) )
199199 }
200200
@@ -219,7 +219,7 @@ impl AccountInfo {
219219 // return the reference to lamports
220220 Ok ( Ref {
221221 value : unsafe { & ( * self . raw ) . lamports } ,
222- state : unsafe { NonNull :: new_unchecked ( & mut ( * self . raw ) . borrow_state ) } ,
222+ state : unsafe { NonNull :: new_unchecked ( borrow_state) } ,
223223 borrow_shift : LAMPORTS_SHIFT ,
224224 } )
225225 }
@@ -240,7 +240,7 @@ impl AccountInfo {
240240 // return the mutable reference to lamports
241241 Ok ( RefMut {
242242 value : unsafe { & mut ( * self . raw ) . lamports } ,
243- state : unsafe { NonNull :: new_unchecked ( & mut ( * self . raw ) . borrow_state ) } ,
243+ state : unsafe { NonNull :: new_unchecked ( borrow_state) } ,
244244 borrow_mask : LAMPORTS_MASK ,
245245 } )
246246 }
@@ -257,7 +257,7 @@ impl AccountInfo {
257257 }
258258
259259 // check if we have reached the max immutable data borrow count (7)
260- if * borrow_state & 0b0111 == 0b0111 {
260+ if * borrow_state & 0b_0111 == 0b0111 {
261261 return Err ( ProgramError :: AccountBorrowFailed ) ;
262262 }
263263
@@ -267,7 +267,7 @@ impl AccountInfo {
267267 // return the reference to data
268268 Ok ( Ref {
269269 value : unsafe { core:: slice:: from_raw_parts ( self . data_ptr ( ) , self . data_len ( ) ) } ,
270- state : unsafe { NonNull :: new_unchecked ( & mut ( * self . raw ) . borrow_state ) } ,
270+ state : unsafe { NonNull :: new_unchecked ( borrow_state) } ,
271271 borrow_shift : DATA_SHIFT ,
272272 } )
273273 }
@@ -283,12 +283,12 @@ impl AccountInfo {
283283 }
284284
285285 // set the mutable data borrow flag
286- * borrow_state |= 0b0000_1000 ;
286+ * borrow_state |= 0b_0000_1000 ;
287287
288288 // return the mutable reference to data
289289 Ok ( RefMut {
290290 value : unsafe { from_raw_parts_mut ( self . data_ptr ( ) , self . data_len ( ) ) } ,
291- state : unsafe { NonNull :: new_unchecked ( & mut ( * self . raw ) . borrow_state ) } ,
291+ state : unsafe { NonNull :: new_unchecked ( borrow_state) } ,
292292 borrow_mask : DATA_MASK ,
293293 } )
294294 }
0 commit comments