]> git.lizzy.rs Git - rust.git/commitdiff
Apply suggestions from code review
authorJake <jh@discordapp.com>
Wed, 4 Aug 2021 06:07:46 +0000 (23:07 -0700)
committerGitHub <noreply@github.com>
Wed, 4 Aug 2021 06:07:46 +0000 (23:07 -0700)
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
crates/hir/src/lib.rs
crates/ide/src/syntax_highlighting/highlight.rs

index 099b488a155ae204a9fe8824fbec7c397e585925..d9fea934b5f7400d70f5fe4e8a521a289a83b799 100644 (file)
@@ -1842,7 +1842,7 @@ pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
 
     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 @@ pub fn is_mutable_reference(&self) -> bool {
     }
 
     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 {
index 19baf5d20d33c019134dcf05ca3b3bb50bb7eac5..53cc3759a40da5dd579d1f95d560c128c84b5192 100644 (file)
@@ -376,7 +376,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, 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))