forked from dbp/sublime-rust
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathsyntax_test_functions.rs
146 lines (129 loc) · 5.13 KB
/
syntax_test_functions.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax"
fn my_func(x: i32)
// <- storage.type.function
// ^^^^^^^ entity.name.function
// ^^^^^^^^ meta.function.parameters
// ^ punctuation.section.parameters.begin
// ^ variable.parameter
// ^ punctuation.separator
// ^ punctuation.section.parameters.end
{
// <- meta.function meta.block punctuation.section.block.begin
}
// <- meta.function meta.block punctuation.section.block.end
fn foo<A>(i: u32, b: i64) -> u32 {
// <- storage.type.function
// ^^^ entity.name.function
// ^ punctuation.definition.generic.begin
// ^ punctuation.definition.generic.end
// ^^^^^^^^^^^^^^^^ meta.function.parameters
// ^^^ storage.type
// ^ meta.block punctuation.section.block.begin
}
// <- meta.block punctuation.section.block.end
fn my_other_func(e: OperatingSystem) -> &'a f64 {
// ^^^^^^^^^^^^^ entity.name.function
// ^ variable.parameter
// ^ punctuation.separator
// ^ meta.function meta.function.return-type keyword.operator
// ^^ meta.function meta.function.return-type storage.modifier.lifetime
// ^^^ meta.function meta.function.return-type storage.type
}
pub fn pub_function() -> bool
// <- storage.modifier
// ^^ storage.type.function
// ^^^^^^^^^^^^ entity.name.function
{
// <- meta.function
return true
// ^^^^^^ meta.function meta.block keyword.control
}
pub unsafe extern "C" fn __sync_synchronize() { }
// <- storage.modifier
// ^^^^^^ storage.modifier
// ^^^^^^ keyword.other
// ^^^ string.quoted.double
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
// ^^ storage.type.function
// ^^^^^^^^^^^^^^^^^^ entity.name.function
// ^ meta.function.parameters punctuation.section.parameters.begin
// ^ meta.function.parameters punctuation.section.parameters.end
let f: extern "C" fn () = mem::transmute(0xffff0fa0u32);
// ^^^^^^ keyword.other
// ^^^ string.quoted.double
// ^^ storage.type.function
// ^^ meta.group
// ^ keyword.operator.assignment
// ^^^^^^^^^^ meta.group constant.numeric.integer.hexadecimal
// ^^^ meta.group storage.type.numeric
// Raw pointer in a parameter.
fn f(a: *const u8, b: *mut i8) {}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters
// ^^^^^ storage.modifier
// ^^^ storage.modifier
// Test irrefutable patterns in params. Most of these tests are in `syntax_test_closure.rs`.
fn f(self,
// ^^^^^^^ meta.function meta.function.parameters
// ^^^^ variable.parameter
(a, b): Tuple,
// ^^^^^^ meta.group
// ^ punctuation.section.group.begin
// ^ variable.parameter
// ^ variable.parameter
// ^ punctuation.section.group.end
// ^ punctuation.separator
Struct{field: c}: Struct,
// ^^^^^^^^^^ meta.block
// ^ punctuation.section.block.begin
// ^ variable.parameter
// ^ punctuation.section.block.end
// ^ punctuation.separator
TupleStruct{0: d}: TupleStruct,
// ^^^^^^ meta.block
// ^ punctuation.section.block.begin
// ^ constant.numeric.integer.decimal
// ^ variable.parameter
// ^ punctuation.section.block.end
// ^ punctuation.separator
[e, f]: Slice)
// ^^^^^^ meta.brackets
// ^ punctuation.section.brackets.begin
// ^ variable.parameter
// ^ variable.parameter
// ^ punctuation.section.brackets.end
// ^ punctuation.separator
{}
const fn f() {}
// <- storage.modifier
// ^^ meta.function storage.type.function
// ^ meta.function entity.name.function
const unsafe fn f() {}
// <- storage.modifier
// ^^^^^^ storage.modifier
// ^^ meta.function storage.type.function
// ^ meta.function entity.name.function
const extern "C" fn f() {}
// <- storage.modifier
// ^^^^^^ keyword.other
// ^^^ string.quoted.double
// ^^ meta.function storage.type.function
// ^ meta.function entity.name.function
fn foo(&'a self) {}
// ^^^^^^^^ meta.function meta.function.parameters
// ^ keyword.operator
// ^^ storage.modifier.lifetime
// ^^^^ variable.parameter
fn sum((x, y): (i32, i32)) -> i32 {
// ^^^^^^ meta.group
// ^ punctuation.section.group.begin
// ^ variable.parameter
// ^ punctuation.separator
// ^ variable.parameter
// ^ punctuation.section.group.end
// ^ punctuation.separator
// ^ punctuation.section.group.begin
// ^^^ storage.type
// ^ punctuation.separator
// ^^^ storage.type
// ^ punctuation.section.group.end