-
-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathConstants.ts
68 lines (66 loc) · 1.34 KB
/
Constants.ts
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
import { checkForReservedKeyword } from '../../helpers';
export const RESERVED_RUST_KEYWORDS = [
// strict keywords can only be used in correct context, and are therefore invalid as:
// Items, variables and function parameters, fields and vairants, type parameters, lifetime parameters, loop labels, macros or attributes, macro placeholders
// https://doc.rust-lang.org/reference/keywords.html#strict-keywords
'as',
'async',
'await',
'break',
'const',
'continue',
'crate',
'dyn',
'else',
'enum',
'extern',
'false',
'fn',
'for',
'if',
'impl',
'in',
'let',
'loop',
'match',
'mod',
'move',
'mut',
'pub',
'ref',
'return',
'self',
'Self',
'static',
'struct',
'super',
'trait',
'true',
'try',
'type',
'unsafe',
'use',
'where',
'while',
// weak keywrods
// these keywords have special meaning only in certain contexts, but are included as reserved keywords here for simplicity
'union',
"'static",
'macro_rules',
// keywords reserved for future use
// https://doc.rust-lang.org/reference/keywords.html#reserved-keywords
'abstract',
'become',
'box',
'do',
'final',
'macro',
'override',
'priv',
'typeof',
'unsized',
'yield'
];
export function isReservedRustKeyword(word: string): boolean {
return checkForReservedKeyword(word, RESERVED_RUST_KEYWORDS, false);
}