mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
parent
28b6a30752
commit
e01ff775ae
2 changed files with 4 additions and 4 deletions
|
@ -1842,7 +1842,7 @@ impl Local {
|
||||||
|
|
||||||
pub fn is_ref(self, db: &dyn HirDatabase) -> bool {
|
pub fn is_ref(self, db: &dyn HirDatabase) -> bool {
|
||||||
let body = db.body(self.parent);
|
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 {
|
pub fn parent(self, _db: &dyn HirDatabase) -> DefWithBody {
|
||||||
|
@ -2201,7 +2201,7 @@ impl Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_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 {
|
pub fn is_usize(&self) -> bool {
|
||||||
|
|
|
@ -376,7 +376,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
||||||
h |= HlMod::Associated;
|
h |= HlMod::Associated;
|
||||||
match func.self_param(db) {
|
match func.self_param(db) {
|
||||||
Some(sp) => match sp.access(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,
|
hir::Access::Shared => h |= HlMod::Reference,
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
@ -555,7 +555,7 @@ fn highlight_method_call(
|
||||||
if let Some(self_param) = func.self_param(sema.db) {
|
if let Some(self_param) = func.self_param(sema.db) {
|
||||||
match self_param.access(sema.db) {
|
match self_param.access(sema.db) {
|
||||||
hir::Access::Shared => h |= HlMod::Reference,
|
hir::Access::Shared => h |= HlMod::Reference,
|
||||||
hir::Access::Exclusive => h |= HlMod::Mutable,
|
hir::Access::Exclusive => h | HlMod::Mutable | HlMod::Reference,
|
||||||
hir::Access::Owned => {
|
hir::Access::Owned => {
|
||||||
if let Some(receiver_ty) =
|
if let Some(receiver_ty) =
|
||||||
method_call.receiver().and_then(|it| sema.type_of_expr(&it))
|
method_call.receiver().and_then(|it| sema.type_of_expr(&it))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue