Skip to content

Commit 1b2a404

Browse files
committed
Syntax: Support comments near struct/union.
1 parent 24e5f8e commit 1b2a404

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

RustEnhanced.sublime-syntax

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ contexts:
540540

541541
struct-identifier:
542542
- meta_scope: meta.struct.rust
543+
- include: comments
543544
- match: '{{identifier}}(?=<)'
544545
scope: entity.name.struct.rust
545546
set:
@@ -608,6 +609,7 @@ contexts:
608609

609610
union-identifier:
610611
- meta_scope: meta.union.rust
612+
- include: comments
611613
- match: '{{identifier}}(?=<)'
612614
scope: entity.name.union.rust
613615
set:

tests/syntax-rust/syntax_test_struct.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct Pair(i32, i32);
3131
// ^^^ storage.type
3232
// ^ - meta.struct
3333

34+
struct /*comment*/ Comments {}
35+
// ^^^^^^^^^^^ meta.struct comment.block
36+
3437
struct Point
3538
// ^^^^^^^^^ meta.struct
3639
{

tests/syntax-rust/syntax_test_union.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ pub union Foo<'a, Y: Baz>
3535
// that we don't accidentally interpret it as a keyword.
3636
fn union() {}
3737
// ^^^^^ meta.function entity.name.function
38+
39+
union /*comment*/ U {}
40+
// ^^^^^^^^^^^ meta.union comment.block

0 commit comments

Comments
 (0)