Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions RustEnhanced.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,10 @@ contexts:
struct-body:
- meta_scope: meta.struct.rust
- include: comments
- match: '(?=\bwhere\b)'
push: impl-where
- match: '(?=\()'
set: struct-tuple
push: struct-tuple
- match: '(?=\{)'
set: struct-classic
- match: '(?=;)'
Expand Down Expand Up @@ -663,7 +665,7 @@ contexts:
- match: '(?=\{)'
set: impl-body
- match: '(?=\bwhere\b)'
set: impl-where
push: impl-where
- match: '{{identifier}}(?=<)'
scope: entity.name.impl.rust
push: generic-angles
Expand All @@ -677,25 +679,25 @@ contexts:
scope: storage.modifier.lifetime.rust

impl-where:
- meta_scope: meta.impl.rust
- meta_scope: meta.where.rust
- include: comments
- match: '(?=\{)'
set: impl-body
- match: '(?=(\{|;))'
pop: true
- match: \bwhere\b
scope: keyword.other.rust
- match: \bfor\b
scope: keyword.other.rust
push:
- match: '(?=<)'
push: generic-angles
- include: basic-identifiers
- include: type-any-identifier
- match: '&'
scope: keyword.operator.rust
- match: '''{{identifier}}(?!\'')\b'
scope: storage.modifier.lifetime.rust
- match: '(?=\S)'
pop: true
- include: basic-identifiers
- include: type-any-identifier
- match: ':'
scope: punctuation.separator.rust

Expand Down Expand Up @@ -755,7 +757,7 @@ contexts:
pop: true

fn-where:
- meta_scope: meta.function.rust
- meta_scope: meta.function.rust meta.where.rust
- include: comments
- match: '(?=\{)'
set: fn-body
Expand All @@ -766,14 +768,14 @@ contexts:
push:
- match: '(?=<)'
push: generic-angles
- include: basic-identifiers
- include: type-any-identifiers
- match: '&'
scope: keyword.operator.rust
- match: '''{{identifier}}(?!\'')\b'
scope: storage.modifier.lifetime.rust
- match: '(?=\S)'
pop: true
- include: basic-identifiers
- include: type-any-identifiers
- match: ':'
scope: punctuation.separator.rust
- match: ';'
Expand Down
36 changes: 34 additions & 2 deletions syntax_test_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ impl<'a, T: MyTrait + OtherTrait> PrintInOption for T where
// ^ keyword.operator
// ^^^ keyword.other
// ^ entity.name.impl
// ^^^^^ keyword.other
// ^^^^^ meta.where keyword.other
Option<T>: Debug {
//^^^^^^^^^^^^^^^^^^^^ meta.impl
fn print_in_option(self) {
Expand Down Expand Up @@ -948,7 +948,7 @@ pub fn new<T>() -> Fibonacci<T>

pub fn new<T>() -> Fibonacci<T>
where for <'a> &'a T: Add<Output = T>,
// ^^^^^ keyword.other.rust
// ^^^^^ meta.where keyword.other.rust
// ^^^ keyword.other.rust
// ^ punctuation.definition.generic.begin.rust
// ^^ storage.modifier.lifetime.rust
Expand Down Expand Up @@ -1066,3 +1066,35 @@ fn numbers() -> impl Iterator<Item = u64> {
Generator(move || for a in (0..10) { yield a; } })
// ^^^^^ keyword.control
}

pub struct IterHolder<A> where A: Number {
// ^^^ meta.struct meta.generic
// ^^^^^ meta.struct meta.where keyword.other
// ^^^^^^ meta.struct meta.where
// ^ meta.struct punctuation.definition.block.begin.rust
num: A
}

pub struct IterHolder<A>
// ^^^ meta.struct meta.generic
where
// <- meta.struct meta.where keyword.other
A: Number {
// ^^^^^^ meta.struct meta.where
num: A
}

struct A<T>(T) where T: AsRef<str>;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.struct
// ^^^ meta.struct meta.where storage.type
// ^ punctuation.terminator
// ^^^^^ meta.struct meta.where keyword.other
pub struct A<T>(T)
//^^^^^^^^^^^^ meta.struct
// ^^^^^^ meta.struct storage.type
where
//^^^ meta.struct meta.where keyword.other
T: AsRef<str>;
//^^^^^^^^^^^^^^^ meta.struct
// ^^^ meta.struct meta.where storage.type
// ^ punctuation.terminator