diff --git a/RustEnhanced.sublime-syntax b/RustEnhanced.sublime-syntax index adc156c8..b3d9a820 100644 --- a/RustEnhanced.sublime-syntax +++ b/RustEnhanced.sublime-syntax @@ -422,7 +422,7 @@ contexts: - match: '<' scope: punctuation.definition.generic.begin.rust push: generic-angles-contents - # Alert the user of a broken generic construct + # Alert the use of a broken generic construct - match: '.' scope: invalid.illegal.rust pop: true @@ -435,13 +435,7 @@ contexts: - include: strings - match: '(?=\S)' pop: true - - match: '\[' - scope: punctuation.definition.group.begin.rust - push: - - match: '\]' - scope: punctuation.definition.group.end.rust - pop: true - - include: type-any-identifier + - include: type-slice - match: '(?=>)' pop: true - match: '<' @@ -502,9 +496,19 @@ contexts: pop: true - include: type-any-identifier - include: type + - include: type-slice - match: '\b_\b' scope: keyword.operator.rust + type-slice: + - match: '\[' + scope: punctuation.definition.group.begin.rust + push: + - match: '\]' + scope: punctuation.definition.group.end.rust + pop: true + - include: type-any-identifier + struct-identifier: - match: '{{identifier}}(?=<)' scope: entity.name.struct.rust @@ -830,14 +834,14 @@ contexts: push: - match: '(?=<)' push: generic-angles - - include: type-any-identifiers + - include: type-any-identifier - match: '&' scope: keyword.operator.rust - match: '''{{identifier}}(?!\'')\b' scope: storage.modifier.lifetime.rust - match: '(?=\S)' pop: true - - include: type-any-identifiers + - include: type-any-identifier - match: ':' scope: punctuation.separator.rust - match: ';' diff --git a/syntax_test_rust.rs b/syntax_test_rust.rs index 19411025..a97342a0 100644 --- a/syntax_test_rust.rs +++ b/syntax_test_rust.rs @@ -1203,3 +1203,74 @@ pub union Foo<'a, Y: Baz> // that we don't accidentally interpret it as a keyword. fn union() {} // ^^^^^ meta.function entity.name.function + +fn f<'b: 'a>(self) -> &'b mut [i32] where 'a: 'b { } +// ^^^^^^^^^^^^^^ meta.function meta.function.return-type +// ^ meta.function meta.function.return-type punctuation.definition.group.begin +// ^^^ meta.function meta.function.return-type storage.type +// ^ meta.function meta.function.return-type punctuation.definition.group.end +// ^^^^^ meta.function meta.where keyword.other +// ^^ meta.function meta.where storage.modifier.lifetime +// ^ meta.function meta.where punctuation.separator +// ^^ meta.function meta.where storage.modifier.lifetime +// ^ meta.function meta.block punctuation.definition.block.begin +// ^ meta.function meta.block punctuation.definition.block.end + +fn f(func: F) -> usize +// ^^ meta.function meta.function.return-type punctuation.separator +// ^^^^^ meta.function meta.function.return-type storage.type + where F: Fn(usize) -> usize {} +// ^^^^^ meta.function meta.where keyword.other +// ^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where +// ^ punctuation.separator +// ^^ support.type +// ^ punctuation.definition.type.begin +// ^^^^^ storage.type +// ^ punctuation.definition.type.end +// ^^ meta.function.return-type punctuation.separator +// ^^^^^ meta.function.return-type storage.type +// ^ meta.function meta.block punctuation.definition.block.begin +// ^ meta.function meta.block punctuation.definition.block.end + +fn f(lhs: L, rhs: R) + where L: IntoIterator, +// ^^^^^ meta.function meta.where keyword.other +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where +// ^^^^^^^^^^^^ support.type +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^ punctuation.definition.type.begin +// ^ keyword.operator +// ^^ storage.modifier.lifetime +// ^^^ storage.type +// ^ keyword.operator +// ^^ storage.modifier.lifetime +// ^^^ storage.type +// ^ punctuation.definition.type.end +// ^ punctuation.definition.generic.end + R: IntoIterator, {} +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.where +// ^ meta.function meta.block punctuation.definition.block.begin +// ^ meta.function meta.block punctuation.definition.block.end +fn f usize>(func: f) {} +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.generic +// ^ meta.generic punctuation.definition.generic.begin +// ^ meta.generic punctuation.separator +// ^^ meta.generic support.type +// ^ meta.generic punctuation.definition.type.begin +// ^^^^^ meta.generic storage.type +// ^ meta.generic punctuation.definition.type.end +// ^^^^^ meta.generic meta.function.return-type storage.type +// ^ meta.generic punctuation.definition.generic.end +// ^ meta.function meta.function.parameters punctuation.definition.parameters.begin +// ^^^^ meta.function meta.function.parameters variable.parameter +fn f>(lhs: L) {} +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^ punctuation.definition.generic.begin +// ^ punctuation.definition.type.begin +// ^^ storage.modifier.lifetime +// ^^^ storage.type +// ^ punctuation.definition.generic.begin +// ^ punctuation.definition.generic.end +// ^ meta.function meta.function.parameters punctuation.definition.parameters.begin