@@ -216,7 +216,9 @@ impl<'a> FragmentCtx<'a> {
216216 } ) ;
217217 return ;
218218 }
219- let mut access = self . builder . classify_access ( token) ;
219+ let mut access = self
220+ . builder
221+ . classify_access ( token, param. is_refcount_pointer ) ;
220222 if param. is_mut_ref && self . text_buf . ends_with ( '*' ) {
221223 self . text_buf . pop ( ) ;
222224 }
@@ -392,7 +394,7 @@ impl<'a> FnIrBuilder<'a> {
392394 generics
393395 }
394396
395- fn classify_rw_from_name_ref ( & self , name_ref : & ast:: NameRef ) -> Access {
397+ fn classify_rw_from_name_ref ( & self , name_ref : & ast:: NameRef , is_ptr : bool ) -> Access {
396398 name_ref
397399 . syntax ( )
398400 . ancestors ( )
@@ -425,7 +427,8 @@ impl<'a> FnIrBuilder<'a> {
425427 {
426428 return None ;
427429 }
428- Some ( Access :: Unknown )
430+ // Every Ptr method takes &self.
431+ Some ( if is_ptr { Access :: Borrow } else { Access :: Unknown } )
429432 } ,
430433 ast:: ReturnExpr ( _) => {
431434 panic!( "return statements are not supported in rule bodies" ) ;
@@ -461,12 +464,12 @@ impl<'a> FnIrBuilder<'a> {
461464 . is_some_and ( |ty| matches ! ( ty, ast:: Type :: RefType ( r) if r. mut_token( ) . is_some( ) ) )
462465 }
463466
464- fn classify_access ( & self , token : & ra_ap_syntax:: SyntaxToken ) -> Access {
467+ fn classify_access ( & self , token : & ra_ap_syntax:: SyntaxToken , is_ptr : bool ) -> Access {
465468 let Some ( name_ref) = token. parent ( ) . and_then ( ast:: NameRef :: cast) else {
466469 // Inside a macro invocation. Phase 2 will resolve this.
467470 return Access :: Unknown ;
468471 } ;
469- self . classify_rw_from_name_ref ( & name_ref)
472+ self . classify_rw_from_name_ref ( & name_ref, is_ptr )
470473 }
471474
472475 fn trim_whitespaces ( fragments : & mut Vec < BodyFragment > ) {
0 commit comments