diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d9fea934b5..e32b075944 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1842,7 +1842,10 @@ 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 | BindingAnnotation::RefMut, .. }) + matches!( + &body[self.pat_id], + Pat::Bind { mode: BindingAnnotation::Ref | BindingAnnotation::RefMut, .. } + ) } pub fn parent(self, _db: &dyn HirDatabase) -> DefWithBody { diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 53cc3759a4..60fb38e182 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -460,8 +460,6 @@ fn highlight_def(db: &RootDatabase, krate: Option, def: Definition) if s.is_mut(db) { h |= HlMod::Mutable; h |= HlMod::Unsafe; - } else { - h |= HlMod::Reference; } h @@ -489,7 +487,7 @@ fn highlight_def(db: &RootDatabase, krate: Option, def: Definition) let ty = local.ty(db); if local.is_mut(db) || ty.is_mutable_reference() { h |= HlMod::Mutable; - } + } if local.is_ref(db) || ty.is_reference() { h |= HlMod::Reference; } @@ -555,7 +553,10 @@ 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 | HlMod::Reference, + hir::Access::Exclusive => { + h |= HlMod::Mutable; + h |= HlMod::Reference; + } hir::Access::Owned => { if let Some(receiver_ty) = method_call.receiver().and_then(|it| sema.type_of_expr(&it)) diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index c566acca64..88a348115b 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -83,8 +83,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd f.baz(self) } - fn qux(&mut self) { - self.x = 0; + fn qux(&mut self) { + self.x = 0; } fn quop(&self) -> i32 { @@ -102,8 +102,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd f.baz(self) } - fn qux(&mut self) { - self.x = 0; + fn qux(&mut self) { + self.x = 0; } fn quop(&self) -> u32 { @@ -197,8 +197,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut x = 42; x += 1; - let y = &mut x; - let z = &y; + let y = &mut x; + let z = &y; let Foo { x: z, y } = Foo { x: z, y }; @@ -207,12 +207,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut foo = Foo { x, y: x }; let foo2 = Foo { x, y: x }; foo.quop(); - foo.qux(); + foo.qux(); foo.baz(foo2); let mut copy = FooCopy { x }; copy.quop(); - copy.qux(); + copy.qux(); copy.baz(copy); let a = |x| x; diff --git a/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html b/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html index 7107991055..f0c96412f1 100644 --- a/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html @@ -49,5 +49,5 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } fn bar() { - let mut hello = "hello"; + let mut hello = "hello"; } \ No newline at end of file