@@ -85,14 +85,14 @@ var RustHighlightRules = function() {
85
85
]
86
86
} , {
87
87
token : [ 'keyword.source.rust' , 'text' , 'entity.name.function.source.rust' , 'punctuation' ] ,
88
- regex : '\\b(fn)(\\s+)((?:r#)?' + wordPattern + ')(<)' ,
88
+ regex : '\\b(fn)(\\s+)((?:r#)?' + wordPattern + ')(<)(?!<) ' ,
89
89
push : "generics"
90
90
} , {
91
91
token : [ 'keyword.source.rust' , 'text' , 'entity.name.function.source.rust' ] ,
92
92
regex : '\\b(fn)(\\s+)((?:r#)?' + wordPattern + ')'
93
93
} , {
94
94
token : [ 'support.constant' , "punctuation" ] ,
95
- regex : "(" + wordPattern + '::)(<)' ,
95
+ regex : "(" + wordPattern + '::)(<)(?!<) ' ,
96
96
push : "generics"
97
97
} , {
98
98
token : 'support.constant' ,
@@ -126,12 +126,15 @@ var RustHighlightRules = function() {
126
126
]
127
127
} , {
128
128
token : [ "keyword.source.rust" , "identifier" , "punctuaction" ] ,
129
- regex : "(?:(impl)|(" + wordPattern + "))(<)" ,
129
+ regex : "(?:(impl)|(" + wordPattern + "))(<)(?!<) " ,
130
130
stateName : 'generics' ,
131
131
push : [
132
132
{
133
+ token : 'keyword.operator' ,
134
+ regex : / < < | = /
135
+ } , {
133
136
token : "punctuaction" ,
134
- regex : "<" ,
137
+ regex : "<(?!<) " ,
135
138
push : "generics"
136
139
} , {
137
140
token : 'variable.other.source.rust' , // `(?![\\\'])` to keep a lifetime name highlighting from continuing one character
@@ -141,51 +144,55 @@ var RustHighlightRules = function() {
141
144
} , {
142
145
token : "storage.type.source.rust" ,
143
146
regex : "\\b(u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|char|bool)\\b"
144
- } , {
145
- token : "punctuation.operator" ,
146
- regex : "[,:]"
147
147
} , {
148
148
token : "keyword" ,
149
149
regex : "\\b(?:const|dyn)\\b"
150
150
} , {
151
151
token : "punctuation" ,
152
152
regex : ">" ,
153
153
next : "pop"
154
- } , {
155
- token : "paren.lparen" ,
156
- regex : "[(]"
157
- } , {
158
- token : "paren.rparen" ,
159
- regex : "[)]"
160
- } , {
154
+ } ,
155
+ { include : "punctuation" } ,
156
+ { include : "operators" } ,
157
+ { include : "constants" } ,
158
+ {
161
159
token : "identifier" ,
162
160
regex : "\\b" + wordPattern + "\\b"
163
- } , {
164
- token : 'keyword.operator' ,
165
- regex : "="
166
161
}
167
162
]
168
163
} , {
169
164
token : keywordMapper ,
170
165
regex : wordPattern
171
166
} , {
172
- token : 'keyword.operator' , // `[*/](?![*/])=?` is separated because `//` and `/* */` become comments and must be
173
- // guarded against. This states either `*` or `/` may be matched as long as the match
174
- // it isn't followed by either of the two. An `=` may be on the end.
175
- regex : / \$ | [ - = ] > | [ - + % ^ = ! & | < > ] = ? | [ * / ] (? ! [ * / ] ) = ? /
176
- } , {
177
- token : "punctuation.operator" ,
178
- regex : / [ ? : , ; . ] /
179
- } , {
167
+ token : 'meta.preprocessor.source.rust' ,
168
+ regex : '\\b\\w\\(\\w\\)*!|#\\[[\\w=\\(\\)_]+\\]\\b'
169
+ } ,
170
+ { include : "punctuation" } ,
171
+ { include : "operators" } ,
172
+ { include : "constants" }
173
+ ] ,
174
+ punctuation : [
175
+ {
180
176
token : "paren.lparen" ,
181
177
regex : / [ \[ ( { ] /
182
178
} , {
183
179
token : "paren.rparen" ,
184
180
regex : / [ \] ) } ] /
185
181
} , {
186
- token : 'meta.preprocessor.source.rust' ,
187
- regex : '\\b\\w\\(\\w\\)*!|#\\[[\\w=\\(\\)_]+\\]\\b'
188
- } , {
182
+ token : "punctuation.operator" ,
183
+ regex : / [ ? : , ; . ] /
184
+ }
185
+ ] ,
186
+ operators : [
187
+ {
188
+ token : 'keyword.operator' , // `[*/](?![*/])=?` is separated because `//` and `/* */` become comments and must be
189
+ // guarded against. This states either `*` or `/` may be matched as long as the match
190
+ // it isn't followed by either of the two. An `=` may be on the end.
191
+ regex : / \$ | [ - = ] > | [ - + % ^ = ! & | < > ] = ? | [ * / ] (? ! [ * / ] ) = ? /
192
+ }
193
+ ] ,
194
+ constants : [
195
+ {
189
196
token : 'constant.numeric.source.rust' ,
190
197
regex : / \b (?: 0 x [ a - f A - F 0 - 9 _ ] + | 0 o [ 0 - 7 _ ] + | 0 b [ 0 1 _ ] + | [ 0 - 9 ] [ 0 - 9 _ ] * (? ! \. ) ) (?: [ i u ] (?: s i z e | 8 | 1 6 | 3 2 | 6 4 | 1 2 8 ) ) ? \b /
191
198
} , {
0 commit comments