From cb5bd6b5af0d9c2f507ba0c80209fd0bee55ab0e Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 23 Nov 2022 22:08:19 +0100 Subject: [PATCH] [Rust] Fix highlighting of unknown generic types --- Rust/Rust.sublime-syntax | 5 +++-- Rust/tests/syntax_test_types.rs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Rust/Rust.sublime-syntax b/Rust/Rust.sublime-syntax index 8a2201e2b89..a9f8e8b58b7 100644 --- a/Rust/Rust.sublime-syntax +++ b/Rust/Rust.sublime-syntax @@ -525,7 +525,6 @@ contexts: scope: keyword.operator.arithmetic.rust - include: integers - include: block - - match: '{{identifier}}' - match: ':|,' scope: punctuation.separator.rust - match: '\+|=' @@ -638,7 +637,7 @@ contexts: pop: true - match: '!' scope: keyword.operator.negated-type.rust - - include: type-identifiers + - include: type-any-identifiers type-any-identifiers: - match: '!' @@ -650,6 +649,7 @@ contexts: - match: '{{type_identifier}}' scope: storage.type.rust - match: '{{identifier}}' + scope: meta.identifier.expected-type.rust support-type: - match: '(Vec|Option|Result|BTreeMap|HashMap|Box|Rc|Arc|AsRef|AsMut|Into|From)\s*(?=<)' @@ -661,6 +661,7 @@ contexts: type: # A low-level type. Typically you want types-any for the full type grammar. - match: '{{identifier}}(?=<)' + scope: storage.type.rust push: generic-angles - match: \b(Self|{{int_suffixes}}|{{float_suffixes}}|bool|char|str)\b scope: storage.type.rust diff --git a/Rust/tests/syntax_test_types.rs b/Rust/tests/syntax_test_types.rs index ae3e89dec87..d4ac9e04fb3 100644 --- a/Rust/tests/syntax_test_types.rs +++ b/Rust/tests/syntax_test_types.rs @@ -158,9 +158,22 @@ type Snail = Vec; // ^ punctuation.definition.generic.end.rust type ExampleRawPointer = HashMap<*const i32, Option, BuildHasherDefault>; -// ^^^^^^ meta.generic storage.modifier +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic.rust +// ^^^^^^ storage.modifier // ^^^ meta.generic storage.type +// ^ punctuation.separator.rust +// ^^^^^^^^^^^ meta.generic.rust meta.generic.rust // ^^^^^^ storage.type.rust support.type.rust +// ^ punctuation.definition.generic.begin.rust +// ^^^ storage.type.rust +// ^ punctuation.definition.generic.end.rust +// ^ punctuation.separator.rust +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic.rust meta.generic.rust +// ^^^^^^^^^^^^^^^^^^ storage.type +// ^ punctuation.definition.generic.begin.rust +// ^^^^^^^^^ storage.type.rust +// ^^ punctuation.definition.generic.end.rust +// ^ punctuation.terminator.rust // Anonymous lifetimes.