aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-19 18:56:19 +0100
committerGitHub <[email protected]>2020-08-19 18:56:19 +0100
commit9051d6bc366804fde7c69074950363fc2956a2e1 (patch)
tree799ea7db698e0de0f241573f9fdf54446f974d1b /crates/ide
parentbb07e6bdee234d4408c3733307d6134597b531ec (diff)
parenteb7bb2cba0b846b32aaf33bc187465f349706431 (diff)
Merge #5822
5822: Remove dead code r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/syntax_highlighting.rs40
1 files changed, 15 insertions, 25 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index db8aaed48..dd8cfe42d 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -484,9 +484,9 @@ fn highlight_element(
484 match name_kind { 484 match name_kind {
485 Some(NameClass::ExternCrate(_)) => HighlightTag::Module.into(), 485 Some(NameClass::ExternCrate(_)) => HighlightTag::Module.into(),
486 Some(NameClass::Definition(def)) => { 486 Some(NameClass::Definition(def)) => {
487 highlight_def(sema, db, def, None) | HighlightModifier::Definition 487 highlight_def(db, def) | HighlightModifier::Definition
488 } 488 }
489 Some(NameClass::ConstReference(def)) => highlight_def(sema, db, def, None), 489 Some(NameClass::ConstReference(def)) => highlight_def(db, def),
490 Some(NameClass::FieldShorthand { field, .. }) => { 490 Some(NameClass::FieldShorthand { field, .. }) => {
491 let mut h = HighlightTag::Field.into(); 491 let mut h = HighlightTag::Field.into();
492 if let Definition::Field(field) = field { 492 if let Definition::Field(field) = field {
@@ -520,7 +520,7 @@ fn highlight_element(
520 } 520 }
521 }; 521 };
522 522
523 let mut h = highlight_def(sema, db, def, Some(name_ref.clone())); 523 let mut h = highlight_def(db, def);
524 524
525 if let Some(parent) = name_ref.syntax().parent() { 525 if let Some(parent) = name_ref.syntax().parent() {
526 if matches!(parent.kind(), FIELD_EXPR | RECORD_PAT_FIELD) { 526 if matches!(parent.kind(), FIELD_EXPR | RECORD_PAT_FIELD) {
@@ -736,34 +736,24 @@ fn highlight_method_call(
736 Some(h) 736 Some(h)
737} 737}
738 738
739fn highlight_def( 739fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight {
740 sema: &Semantics<RootDatabase>,
741 db: &RootDatabase,
742 def: Definition,
743 name_ref: Option<ast::NameRef>,
744) -> Highlight {
745 match def { 740 match def {
746 Definition::Macro(_) => HighlightTag::Macro, 741 Definition::Macro(_) => HighlightTag::Macro,
747 Definition::Field(_) => HighlightTag::Field, 742 Definition::Field(_) => HighlightTag::Field,
748 Definition::ModuleDef(def) => match def { 743 Definition::ModuleDef(def) => match def {
749 hir::ModuleDef::Module(_) => HighlightTag::Module, 744 hir::ModuleDef::Module(_) => HighlightTag::Module,
750 hir::ModuleDef::Function(func) => { 745 hir::ModuleDef::Function(func) => {
751 return name_ref 746 let mut h = HighlightTag::Function.into();
752 .and_then(|name_ref| highlight_func_by_name_ref(sema, &name_ref)) 747 if func.is_unsafe(db) {
753 .unwrap_or_else(|| { 748 h |= HighlightModifier::Unsafe;
754 let mut h = HighlightTag::Function.into(); 749 }
755 if func.is_unsafe(db) { 750 if let Some(self_param) = func.self_param(db) {
756 h |= HighlightModifier::Unsafe; 751 match self_param.access(db) {
757 } 752 hir::Access::Exclusive => h |= HighlightModifier::Mutable,
758 753 hir::Access::Shared | hir::Access::Owned => (),
759 match func.self_param(db) { 754 }
760 None => h, 755 }
761 Some(self_param) => match self_param.access(db) { 756 return h;
762 hir::Access::Exclusive => h | HighlightModifier::Mutable,
763 hir::Access::Shared | hir::Access::Owned => h,
764 },
765 }
766 });
767 } 757 }
768 hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, 758 hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct,
769 hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, 759 hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum,