Skip to content

Commit f0e0d10

Browse files
ehussjasonwilliams
authored andcommitted
Syntax: Support break/continue labels. (rust-lang#302)
1 parent 1b19dbb commit f0e0d10

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

RustEnhanced.sublime-syntax

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ contexts:
2828
- match: ';'
2929
scope: punctuation.terminator
3030

31-
- match: '''({{identifier}})\s*(:)'
31+
- match: '(''{{identifier}})\s*(:)'
3232
captures:
3333
1: entity.name.label.rust
3434
2: punctuation.separator.rust
@@ -138,9 +138,14 @@ contexts:
138138
- match: \b(crate|extern|use|where)\b
139139
scope: keyword.other.rust
140140

141-
- match: \b(break|else|for|if|loop|match|while|continue|yield)\b
141+
- match: \b(else|for|if|loop|match|while|yield)\b
142142
scope: keyword.control.rust
143143

144+
- match: '\b(break|continue)(?:\s+(''{{identifier}}))?'
145+
captures:
146+
1: keyword.control.rust
147+
2: entity.name.label.rust
148+
144149
- match: \breturn\b
145150
scope: keyword.control.rust
146151

syntax_test_rust.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,23 @@ let big_n =
619619
}
620620
}
621621

622+
'label1: for _ in 0..100 {
623+
'label2 : loop {
624+
// ^^^^^^^ entity.name.label
625+
// ^ punctuation.separator.rust
626+
'label3: while true {
627+
// ^^^^^^^ entity.name.label
628+
// ^ punctuation.separator
629+
break 'label2;
630+
// ^^^^^^^ entity.name.label
631+
// ^ punctuation.terminator
632+
}
633+
continue 'label1;
634+
// ^^^^^^^ entity.name.label
635+
// ^ punctuation.terminator
636+
}
637+
}
638+
622639
while n < 50 {
623640
//^^^ keyword.control
624641
n = n * 2;

0 commit comments

Comments
 (0)