Skip to content

Commit fe92d59

Browse files
authored
Merge pull request #431 from ehuss/hq-sync
Synchronize syntax with sublime hq.
2 parents 2fa9158 + 1aff33a commit fe92d59

20 files changed

+908
-317
lines changed

RustEnhanced.sublime-syntax

Lines changed: 217 additions & 79 deletions
Large diffs are not rendered by default.
Lines changed: 99 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax"
22

33
#![warn(unused)]
4-
// <- meta.annotation
4+
// <- meta.annotation punctuation.definition.annotation
55
//^^^^^^^^^^^^^^ meta.annotation
6-
// ^^^^ support.function
7-
// ^ meta.group punctuation.definition.group.begin
8-
// ^^^^^^ meta.group
9-
// ^ meta.group punctuation.definition.group.end
6+
//^ punctuation.section.group.begin
7+
// ^^^^ variable.annotation
8+
// ^^^^^^^^ meta.annotation.parameters meta.group
9+
// ^ punctuation.section.group.begin
10+
// ^ punctuation.section.group.end
11+
// ^ punctuation.section.group.end
1012

11-
#[macro_use]
12-
// <- meta.annotation
13-
//^^^^^^^^^^ meta.annotation
13+
# [ macro_use ]
14+
//^^^^^^^^^^^^^^^ meta.annotation
15+
//^ punctuation.definition.annotation
16+
// ^ punctuation.section.group.begin
17+
// ^^^^^^^^^ variable.annotation
18+
// ^ punctuation.section.group.end
1419

1520
#[cfg(all(unix, not(target_os = "haiku")))]
16-
// <- meta.annotation
21+
// <- meta.annotation punctuation.definition.annotation
1722
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation
18-
//^^^ support.function
19-
// ^^^ meta.group support.function
20-
// ^^^^^^ meta.group meta.group
21-
// ^^^ meta.group meta.group support.function
22-
// ^^^^^^^^^^ meta.group meta.group meta.group
23-
// ^ meta.group meta.group meta.group keyword.operator
24-
// ^^^^^^^ meta.group meta.group meta.group string.quoted.double
23+
//^^^ variable.annotation
24+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.parameters meta.group
25+
// ^ punctuation.section.group.begin
26+
// ^^^ meta.function-call variable.function
27+
// ^ meta.annotation.parameters meta.group meta.function-call meta.group punctuation.section.group.begin
28+
// ^ punctuation.separator
29+
// ^^^ meta.function-call meta.function-call variable.function
30+
// ^ punctuation.section.group.begin
31+
// ^ keyword.operator.assignment
32+
// ^^^^^^^ string.quoted.double
33+
// ^ punctuation.section.group.end
34+
// ^ punctuation.section.group.end
35+
// ^ punctuation.section.group.end
36+
// ^ punctuation.section.group.end
2537

2638
// Test highlighting/scope with struct field attributes
2739
// https://github.com/rust-lang/sublime-rust/issues/120
@@ -35,7 +47,7 @@ pub struct Claim {
3547
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation
3648
pub referring: Option<String>,
3749
#[serde(skip_serializing_if="Option::is_none")]
38-
// ^^^^^ support.function
50+
// ^^^^^ variable.annotation
3951
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation
4052
pub drug: Option<Vec<String>>,
4153
#[serde(skip_serializing_if="Option::is_none")]
@@ -50,7 +62,7 @@ pub struct Claim {
5062
enum E {
5163
#[allow(dead_code)]
5264
// ^^^^^^^^^^^^^^^^^^^ meta.enum meta.annotation
53-
// ^^^^^ support.function
65+
// ^^^^^ variable.annotation
5466
A(i32),
5567
// ^^^ meta.enum meta.struct meta.group storage.type
5668
}
@@ -59,3 +71,72 @@ enum E {
5971
unsafe impl<#[may_dangle] T: ?Sized> Drop for Box<T> { }
6072
// ^^^^^^^^^^^^^ meta.annotation
6173
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.impl meta.generic
74+
75+
#[test = "foo ] bar"]
76+
//^^^^^^^^^^^^^^^^^^^^^ meta.annotation
77+
//^ punctuation.definition.annotation
78+
// ^ punctuation.section.group.begin
79+
// ^^^^ variable.annotation
80+
// ^ keyword.operator.assignment
81+
// ^^^^^^^^^^^ string.quoted.double
82+
// ^ punctuation.section.group.end
83+
84+
// All the things.
85+
# ! [
86+
//^^^^^^ meta.annotation
87+
//^ punctuation.definition.annotation
88+
// ^ punctuation.definition.annotation
89+
// ^ punctuation.section.group.begin
90+
// comment
91+
// ^^^^^^^^^^^ comment.line.double-slash
92+
attr_name (
93+
// ^^^^^^^^^ variable.annotation
94+
// ^ meta.annotation.parameters meta.group punctuation.section.group.begin
95+
// comment
96+
// ^^^^^^^^^^^ comment.line.double-slash
97+
"string",
98+
// ^^^^^^^^ string.quoted.double
99+
// ^ punctuation.separator
100+
r##"raw"##,
101+
// ^^^^^^^^^^ string.quoted.double.raw
102+
b"bytes",
103+
// ^ storage.type.string
104+
// ^^^^^^^^ string.quoted.double
105+
br"raw byte",
106+
// ^^^^^^^^^^^^ string.quoted.double.raw
107+
'c',
108+
// ^^^ string.quoted.single
109+
b'c',
110+
// ^^^^ string.quoted.single
111+
1_000,
112+
// ^^^^^ constant.numeric.integer.decimal
113+
1.618,
114+
// ^^^^^ constant.numeric.float
115+
true,
116+
// ^^^^ constant.language
117+
struct,
118+
// ^^^^^^ storage.type.struct
119+
1 + 1,
120+
// ^ constant.numeric.integer.decimal
121+
// ^ keyword.operator.arithmetic
122+
// ^ constant.numeric.integer.decimal
123+
)
124+
// ^ punctuation.section.group.end
125+
]
126+
//^ punctuation.section.group.end
127+
128+
// quote! uses #var syntax
129+
#[doc=#foo]
130+
//^^^^^^^^^ meta.annotation
131+
// ^ keyword.operator.assignment
132+
133+
// Macros often use replacement.
134+
#[doc = $doc]
135+
//^^^^^^^^^^^ meta.annotation
136+
// ^ punctuation.section.group.end
137+
// ^ keyword.operator.assignment
138+
139+
#[rustfmt::skip]
140+
//^^^^^^^^^^^^^^ meta.annotation
141+
//^^^^^^^^^^^^^ meta.path
142+
// ^^^^ variable.annotation

tests/syntax-rust/syntax_test_closures.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,48 @@ let inferred_closure = |i, j: u32| i + 1;
44
// ^^^^^^^^^^^^^^^^ entity.name.function
55
// ^^^^^^^^^^^^^^^^^ meta.function.closure
66
// ^^^^^^^^^^^ meta.function.parameters
7-
// ^ punctuation.definition.parameters.begin
7+
// ^ punctuation.section.parameters.begin
88
// ^ variable.parameter
9+
// ^ punctuation.separator
910
// ^ variable.parameter
1011
// ^ punctuation.separator
1112
// ^^^ storage.type
12-
// ^ punctuation.definition.parameters.end
13+
// ^ punctuation.section.parameters.end
1314
let closure = || -> i32 { | | 1 + 2 };
1415
// ^^^^^^^ entity.name.function
1516
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.closure
1617
// ^^ meta.function.parameters
17-
// ^ punctuation.definition.parameters.begin
18-
// ^ punctuation.definition.parameters.end
18+
// ^ punctuation.section.parameters.begin
19+
// ^ punctuation.section.parameters.end
1920
// ^^^ storage.type
2021
// ^^^^^^^^^^^^^ meta.block
21-
// ^ meta.block punctuation.definition.block.begin
22+
// ^ meta.block punctuation.section.block.begin
2223
// ^ constant.numeric.integer.decimal
2324
// ^ constant.numeric.integer.decimal
24-
// ^ meta.block punctuation.definition.block.end
25+
// ^ meta.block punctuation.section.block.end
2526

2627
// Make sure "or" is not confused with closure.
2728
let c = a | b;
28-
// ^ keyword.operator
29+
// ^ keyword.operator.bitwise
2930

3031
call_func(|c| 1 + 2 + c);
3132
// ^^^^^^^^^^^^^ meta.function.closure
3233
// ^^^ meta.function.parameters
3334

3435
fn lambdas() {
3536
let c = |foo,
36-
// ^ meta.function.closure meta.function.parameters punctuation.definition.parameters.begin
37+
// ^ meta.function.closure meta.function.parameters punctuation.section.parameters.begin
3738
// ^^^ meta.function.parameters variable.parameter
3839
bar| {};
3940
// ^^^ meta.function.parameters variable.parameter
40-
// ^ meta.function.closure meta.function.parameters punctuation.definition.parameters.end
41+
// ^ meta.function.closure meta.function.parameters punctuation.section.parameters.end
4142
let c = |foo, // weird, but should work
42-
// ^ meta.function.closure meta.function.parameters punctuation.definition.parameters.begin
43+
// ^ meta.function.closure meta.function.parameters punctuation.section.parameters.begin
4344
// ^^^ meta.function.parameters variable.parameter
4445
// ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line
4546
bar| {};
4647
// ^^^ meta.function.parameters variable.parameter
47-
// ^ meta.function.closure meta.function.parameters punctuation.definition.parameters.end
48+
// ^ meta.function.closure meta.function.parameters punctuation.section.parameters.end
4849
}
4950

5051

@@ -179,3 +180,20 @@ let x = |/*comment*/(/*c*/a, [b/*c*/], S{/*c*/f: c})| {};
179180
// ^^^^^^^^^^^ meta.block
180181
// ^^^^^ comment.block
181182
// ^ variable.parameter
183+
184+
let f = |(x, y): (u32, &mut u32)| { x + y };
185+
// ^ punctuation.section.parameters.begin
186+
// ^^^^^^ meta.group
187+
// ^ variable.parameter
188+
// ^ punctuation.separator
189+
// ^ variable.parameter
190+
// ^ punctuation.section.group.end
191+
// ^ punctuation.separator
192+
// ^ punctuation.section.group.begin
193+
// ^^^ storage.type
194+
// ^ punctuation.separator
195+
// ^ keyword.operator
196+
// ^^^ storage.modifier
197+
// ^^^ storage.type
198+
// ^ punctuation.section.group.end
199+
// ^ punctuation.section.parameters.end

tests/syntax-rust/syntax_test_comments.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax"
22

33
// Line comments
4-
// <- comment.line.double-slash
4+
// <- comment.line.double-slash punctuation.definition.comment
55
// ^^^^^^^^^^^^^^ comment.line.double-slash
6+
7+
// <- -comment
8+
69
/// Line doc comments
710
// <- comment.line.documentation
811
// ^^^^^^^^^^^^^ comment.line.documentation
912

1013
/*!
11-
// <- comment.block.documentation
14+
// <- comment.block.documentation punctuation.definition.comment
1215
// <- comment.block.documentation
1316
//^ comment.block.documentation
1417
Block doc comments
@@ -17,6 +20,11 @@ Block doc comments
1720
// ^^^^^^^^^^^^^^^^^^ comment.block.documentation comment.block
1821
*/
1922

23+
/**
24+
*
25+
// ^ comment.block.documentation punctuation.definition.comment
26+
*/
27+
2028
// Verify comment is cleared.
2129
mod a {}
2230
// ^^^^^ -comment

tests/syntax-rust/syntax_test_control_flow.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ for i in 1..10 {
99
// <- keyword.control
1010
// ^^ keyword.operator
1111
// ^ constant.numeric.integer.decimal
12-
// ^^ keyword.operator
12+
// ^^ keyword.operator.range
1313
// ^^ constant.numeric.integer.decimal
1414
println!("I: {}", i);
1515
// ^^^^^^^^^^^^^^^^^^^^^^ meta.block
1616
}
17-
// <- meta.block punctuation.definition.block.end
17+
// <- meta.block punctuation.section.block.end
1818

1919
'label_name: loop {
2020
// ^^^^^^^^ entity.name.label
2121
// ^ punctuation.separator
2222
// ^^^^ keyword.control
23-
// ^ meta.block punctuation.definition.block.begin
23+
// ^ meta.block punctuation.section.block.begin
2424
n += 1;
2525
if n / 2 == 5 {
26-
// ^ keyword.operator
26+
// ^ keyword.operator.arithmetic
2727
continue;
2828
// ^^^^^^^^ keyword.control
2929
}
@@ -51,45 +51,46 @@ for i in 1..10 {
5151
}
5252

5353
if n < 0 {
54-
// ^ meta.block punctuation.definition.block.begin
54+
// ^ meta.block punctuation.section.block.begin
5555
// <- keyword.control
5656
print!("{} is negative", n);
57+
// ^ punctuation.terminator
5758
} else if n > 0 {
58-
// <- meta.block punctuation.definition.block.end
59+
// <- meta.block punctuation.section.block.end
5960
// ^^^ keyword.control
60-
// ^ meta.block punctuation.definition.block.begin
61+
// ^ meta.block punctuation.section.block.begin
6162
// ^^ keyword.control
6263
print!("{0} is positive", n);
6364
} else {
64-
// <- meta.block punctuation.definition.block.end
65+
// <- meta.block punctuation.section.block.end
6566
// ^^^ keyword.control
66-
// ^ meta.block punctuation.definition.block.begin
67+
// ^ meta.block punctuation.section.block.begin
6768
print!("{} is zero", n);
6869
// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block
6970
}
70-
// <- meta.block punctuation.definition.block.end
71+
// <- meta.block punctuation.section.block.end
7172

7273
if let BasicStruct(i) = j {
7374
// ^^^ storage.type
74-
// ^ keyword.operator
75-
// ^ meta.block punctuation.definition.block.begin
75+
// ^ keyword.operator.assignment
76+
// ^ meta.block punctuation.section.block.begin
7677
println!("Basic value: {}", i);
7778
}
78-
// <- meta.block punctuation.definition.block.end
79+
// <- meta.block punctuation.section.block.end
7980

8081
while let BasicStruct(k) = j {
8182
//^^^ keyword.control
8283
// ^^^ storage.type
83-
// ^ keyword.operator
84-
// ^ meta.block punctuation.definition.block.begin
84+
// ^ keyword.operator.assignment
85+
// ^ meta.block punctuation.section.block.begin
8586
println!("Constructed example: {}", j)
8687
j = BasicStruct(j + 1);
8788
if k > 20 {
8889
break;
8990
//^^^ meta.block meta.block keyword.control
9091
}
9192
}
92-
// <- meta.block punctuation.definition.block.end
93+
// <- meta.block punctuation.section.block.end
9394

9495
continue_running();
9596
//^^^^^^^^^^^^^^ support.function

tests/syntax-rust/syntax_test_enum.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ enum OperatingSystem
55
// ^^^^^^^^^^^^^^^^^ meta.enum
66
// ^^^^^^^^^^^^^^^ entity.name.enum
77
{
8-
// <- meta.enum punctuation.definition.block.begin
8+
// <- meta.block meta.enum punctuation.section.block.begin
99
Osx,
1010
// ^^^ meta.enum storage.type.source
1111
Windows,
1212
Linux,
1313
Bsd(String),
1414
// ^^^^^^ support.type
1515
Info { field: i32, value: str }
16-
// ^ punctuation.definition.block.begin
16+
// ^ punctuation.section.block.begin
1717
// ^^^ storage.type
1818
// ^^^ storage.type
19-
// ^ meta.block punctuation.definition.block.end
19+
// ^ meta.block punctuation.section.block.end
2020
}
21-
// <- meta.enum punctuation.definition.block.end
21+
// <- meta.block meta.enum punctuation.section.block.end
2222

2323
let q = Message::Quit;
2424
// ^^^^^^^ storage.type.source
@@ -51,7 +51,7 @@ enum Discriminant {
5151
// ^^ meta.enum constant.other
5252
// ^^^^^^ meta.enum meta.group
5353
// ^ constant.numeric.integer.decimal
54-
// ^^ keyword.operator
54+
// ^^ keyword.operator.bitwise
5555
// ^ constant.numeric.integer.decimal
5656
lowercase,
5757
// ^^^^^^^^^^^ meta.enum

0 commit comments

Comments
 (0)