aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-19 16:03:35 +0100
committerGitHub <[email protected]>2020-08-19 16:03:35 +0100
commita4b7ce94bacbb8a9da28111fba0abeb2a68e9bc2 (patch)
tree1affb36a509f8f6460bf35a53a7f7937338ae805 /crates/ide/src
parent1d19084317fd183ca8a1632cbff1112e72e5969f (diff)
parent61754678fb4923738c91f2702bba6628230dff6e (diff)
Merge #5817
5817: Better API factoring around self access modes r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/syntax_highlighting.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index fc4f56550..5521fd2b1 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -4,7 +4,7 @@ mod injection;
4#[cfg(test)] 4#[cfg(test)]
5mod tests; 5mod tests;
6 6
7use hir::{Name, SelfKind, Semantics, VariantDef}; 7use hir::{Name, Semantics, VariantDef};
8use ide_db::{ 8use ide_db::{
9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
10 RootDatabase, 10 RootDatabase,
@@ -720,15 +720,21 @@ fn highlight_method_call(
720 if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { 720 if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) {
721 h |= HighlightModifier::Unsafe; 721 h |= HighlightModifier::Unsafe;
722 } 722 }
723 723 if let Some(self_param) = func.self_param(sema.db) {
724 sema.method_reciever_kind(&method_call) 724 match self_param.access(sema.db) {
725 .map(|self_kind| match self_kind { 725 hir::Access::Shared => (),
726 SelfKind::Shared => h, 726 hir::Access::Exclusive => h |= HighlightModifier::Mutable,
727 SelfKind::Mutable => h | HighlightModifier::Mutable, 727 hir::Access::Owned => {
728 SelfKind::Consuming => h | HighlightModifier::Consuming, 728 if let Some(receiver_ty) = method_call.expr().and_then(|it| sema.type_of_expr(&it))
729 SelfKind::Copied => h, 729 {
730 }) 730 if !receiver_ty.is_copy(sema.db) {
731 .or_else(|| Some(h)) 731 h |= HighlightModifier::Consuming
732 }
733 }
734 }
735 }
736 }
737 Some(h)
732} 738}
733 739
734fn highlight_name( 740fn highlight_name(