diff --git a/RustEnhanced.sublime-syntax b/RustEnhanced.sublime-syntax index 797e238b..cf4e7215 100644 --- a/RustEnhanced.sublime-syntax +++ b/RustEnhanced.sublime-syntax @@ -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: '(?=;)' @@ -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 @@ -677,10 +679,10 @@ 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 @@ -688,14 +690,14 @@ contexts: 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 @@ -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 @@ -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: ';' diff --git a/syntax_test_rust.rs b/syntax_test_rust.rs index 1d7b4464..25a6b240 100644 --- a/syntax_test_rust.rs +++ b/syntax_test_rust.rs @@ -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: Debug { //^^^^^^^^^^^^^^^^^^^^ meta.impl fn print_in_option(self) { @@ -948,7 +948,7 @@ pub fn new() -> Fibonacci pub fn new() -> Fibonacci where for <'a> &'a T: Add, -// ^^^^^ keyword.other.rust +// ^^^^^ meta.where keyword.other.rust // ^^^ keyword.other.rust // ^ punctuation.definition.generic.begin.rust // ^^ storage.modifier.lifetime.rust @@ -1066,3 +1066,35 @@ fn numbers() -> impl Iterator { Generator(move || for a in (0..10) { yield a; } }) // ^^^^^ keyword.control } + +pub struct IterHolder 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 +// ^^^ meta.struct meta.generic +where +// <- meta.struct meta.where keyword.other + A: Number { +// ^^^^^^ meta.struct meta.where + num: A +} + +struct A(T) where T: AsRef; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.struct +// ^^^ meta.struct meta.where storage.type +// ^ punctuation.terminator +// ^^^^^ meta.struct meta.where keyword.other +pub struct A(T) +//^^^^^^^^^^^^ meta.struct +// ^^^^^^ meta.struct storage.type +where +//^^^ meta.struct meta.where keyword.other + T: AsRef; +//^^^^^^^^^^^^^^^ meta.struct +// ^^^ meta.struct meta.where storage.type +// ^ punctuation.terminator \ No newline at end of file