mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Merge #9734
9734: semantic highlighting: add reference hlmod r=matklad a=jhgg This PR adds the "reference" highlight modifier! I basically went around and looked for `HlMod::Mutable` to find the callsites to add a reference. I think these all make sense! Co-authored-by: Jake Heinz <jh@discordapp.com> Co-authored-by: Jake <jh@discordapp.com>
This commit is contained in:
commit
1b02cafa43
15 changed files with 81 additions and 44 deletions
|
@ -1861,6 +1861,14 @@ impl Local {
|
|||
matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. })
|
||||
}
|
||||
|
||||
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, .. }
|
||||
)
|
||||
}
|
||||
|
||||
pub fn parent(self, _db: &dyn HirDatabase) -> DefWithBody {
|
||||
self.parent.into()
|
||||
}
|
||||
|
@ -2216,6 +2224,10 @@ impl Type {
|
|||
matches!(self.ty.kind(&Interner), TyKind::Ref(hir_ty::Mutability::Mut, ..))
|
||||
}
|
||||
|
||||
pub fn is_reference(&self) -> bool {
|
||||
matches!(self.ty.kind(&Interner), TyKind::Ref(..))
|
||||
}
|
||||
|
||||
pub fn is_usize(&self) -> bool {
|
||||
matches!(self.ty.kind(&Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue