@@ -67,6 +67,13 @@ contexts:
6767 2 : storage.type.struct.rust
6868 push : struct-identifier
6969
70+ - match : ' \b(?:(pub)\s+)?(union)\s+'
71+ scope : meta.union.rust
72+ captures :
73+ 1 : storage.modifier.rust
74+ 2 : storage.type.union.rust
75+ push : union-identifier
76+
7077 - match : ' \b(?:(pub)\s+)?(type)\s+({{identifier}})\b'
7178 captures :
7279 1 : storage.modifier.rust
@@ -547,23 +554,53 @@ contexts:
547554 pop : true
548555 - match : ' \{'
549556 scope : punctuation.definition.block.begin.rust
557+ push : struct-classic-body
558+
559+ struct-classic-body :
560+ - meta_scope : meta.block.rust
561+ - match : ' (?=\})'
562+ pop : true
563+ - include : comments
564+ - include : attribute
565+ - match : \bpub\b
566+ scope : storage.modifier.rust
567+ - match : ' {{identifier}}(?=\s*:)'
568+ scope : variable.other.member.rust
550569 push :
551- - meta_scope : meta.block.rust
552- - match : ' (?=\})'
570+ - match : ' ,|(?=\})'
553571 pop : true
554572 - include : comments
555- - include : attribute
556- - match : \bpub\b
557- scope : storage.modifier.rust
558- - match : ' {{identifier}}(?=\s*:)'
559- scope : variable.other.member.rust
560- push :
561- - match : ' ,|(?=\})'
562- pop : true
563- - include : comments
564- - match : ' :'
565- scope : punctuation.separator.rust
566- - include : type-any-identifier
573+ - match : ' :'
574+ scope : punctuation.separator.rust
575+ - include : type-any-identifier
576+
577+
578+ union-identifier :
579+ - match : ' {{identifier}}(?=<)'
580+ scope : entity.name.union.rust
581+ set :
582+ - meta_scope : meta.union.rust meta.generic.rust
583+ - match : ' (?=<)'
584+ push : generic-angles
585+ - match : ' '
586+ set : union-body
587+ - match : ' {{identifier}}'
588+ scope : entity.name.union.rust
589+ set : union-body
590+
591+ union-body :
592+ - meta_scope : meta.union.rust
593+ - include : comments
594+ - match : ' (?=\bwhere\b)'
595+ push : impl-where
596+ - match : ' \{'
597+ scope : punctuation.definition.block.begin.rust
598+ push : struct-classic-body
599+ - match : ' \}'
600+ scope : meta.block.rust punctuation.definition.block.end.rust
601+ pop : true
602+ - match : ' (?=;)'
603+ pop : true
567604
568605 macro-block :
569606 - meta_scope : meta.macro.rust
0 commit comments