diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 099b488a155a..d9fea934b5f7 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1842,7 +1842,7 @@ impl Local { pub fn is_ref(self, db: &dyn HirDatabase) -> bool { let body = db.body(self.parent); - matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Ref, .. }) + matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Ref | BindingAnnotation::RefMut, .. }) } pub fn parent(self, _db: &dyn HirDatabase) -> DefWithBody { @@ -2201,7 +2201,7 @@ impl Type { } pub fn is_reference(&self) -> bool { - matches!(self.ty.kind(&Interner), TyKind::Ref(hir_ty::Mutability::Not, ..)) + matches!(self.ty.kind(&Interner), TyKind::Ref(..)) } pub fn is_usize(&self) -> bool { diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 19baf5d20d33..53cc3759a40d 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -376,7 +376,7 @@ fn highlight_def(db: &RootDatabase, krate: Option, def: Definition) h |= HlMod::Associated; match func.self_param(db) { Some(sp) => match sp.access(db) { - hir::Access::Exclusive => h |= HlMod::Mutable, + hir::Access::Exclusive => h = h | HlMod::Mutable | HlMod::Reference, hir::Access::Shared => h |= HlMod::Reference, _ => {} }, @@ -555,7 +555,7 @@ fn highlight_method_call( if let Some(self_param) = func.self_param(sema.db) { match self_param.access(sema.db) { hir::Access::Shared => h |= HlMod::Reference, - hir::Access::Exclusive => h |= HlMod::Mutable, + hir::Access::Exclusive => h | HlMod::Mutable | HlMod::Reference, hir::Access::Owned => { if let Some(receiver_ty) = method_call.receiver().and_then(|it| sema.type_of_expr(&it))