Skip to content

Commit

Permalink
[Rust] Fix highlighting of unknown generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll committed Nov 23, 2022
1 parent dfa0200 commit cb5bd6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Rust/Rust.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ contexts:
scope: keyword.operator.arithmetic.rust
- include: integers
- include: block
- match: '{{identifier}}'
- match: ':|,'
scope: punctuation.separator.rust
- match: '\+|='
Expand Down Expand Up @@ -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: '!'
Expand All @@ -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*(?=<)'
Expand All @@ -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
Expand Down
15 changes: 14 additions & 1 deletion Rust/tests/syntax_test_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,22 @@ type Snail = Vec<SnailNum>;
// ^ punctuation.definition.generic.end.rust

type ExampleRawPointer = HashMap<*const i32, Option<i32>, BuildHasherDefault<FnvHasher>>;
// ^^^^^^ 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.
Expand Down

0 comments on commit cb5bd6b

Please sign in to comment.