File tree 2 files changed +85
-0
lines changed
2 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
- [ Lexical structure] ( lexical-structure.md )
10
10
- [ Input format] ( input-format.md )
11
+ - [ Keywords] ( keywords.md )
11
12
- [ Identifiers] ( identifiers.md )
12
13
- [ Comments] ( comments.md )
13
14
- [ Whitespace] ( whitespace.md )
Original file line number Diff line number Diff line change
1
+ # Keywords
2
+
3
+ Rust divides keywords in three categories:
4
+ - [ strict] ( #strict-keywords )
5
+ - [ weak] ( #weak-keywords )
6
+ - [ reserved] ( #reserved-keywords )
7
+
8
+ ## Strict keywords
9
+
10
+ These keywords can only be used in their correct contexts. For example, it is
11
+ not allowed to declare a variable with name ` struct ` .
12
+
13
+ > ** <sup >Lexer:<sup >**
14
+ > KW_AS : ` as `
15
+ > KW_BOX : ` box `
16
+ > KW_BREAK : ` break `
17
+ > KW_CONST : ` const `
18
+ > KW_CONTINUE : ` continue `
19
+ > KW_CRATE : ` crate `
20
+ > KW_ELSE : ` else `
21
+ > KW_ENUM : ` enum `
22
+ > KW_EXTERN : ` extern `
23
+ > KW_FALSE : ` false `
24
+ > KW_FN : ` fn `
25
+ > KW_FOR : ` for `
26
+ > KW_IF : ` if `
27
+ > KW_IMPL : ` impl `
28
+ > KW_IN : ` in `
29
+ > KW_LET : ` let `
30
+ > KW_LOOP : ` loop `
31
+ > KW_MATCH : ` match `
32
+ > KW_MOD : ` mod `
33
+ > KW_MOVE : ` move `
34
+ > KW_MUT : ` mut `
35
+ > KW_PUB : ` pub `
36
+ > KW_REF : ` ref `
37
+ > KW_RETURN : ` return `
38
+ > KW_SELFVALUE : ` self `
39
+ > KW_SELFTYPE : ` Self `
40
+ > KW_STATIC : ` static `
41
+ > KW_STRUCT : ` struct `
42
+ > KW_SUPER : ` super `
43
+ > KW_TRAIT : ` trait `
44
+ > KW_TRUE : ` true `
45
+ > KW_TYPE : ` type `
46
+ > KW_UNSAFE : ` unsafe `
47
+ > KW_USE : ` use `
48
+ > KW_WHERE : ` wher `
49
+ > KW_WHILE : ` while `
50
+
51
+ ## Weak keywords
52
+
53
+ These keywords have special meaning only in certain contexts. For example,
54
+ it is possible to declare a variable or method with the name ` union ` .
55
+
56
+ > ** <sup >Lexer</sup >**
57
+ > KW_CATCH : ` catch `
58
+ > KW_DEFAULT : ` default `
59
+ > KW_UNION : ` union `
60
+ > KW_STATICLIFETIME : ` 'static `
61
+
62
+ ## Reserved keywords
63
+
64
+ These keywords aren't used yet, but they are reserved for future use.
65
+ The reasoning behind this is to make current programs forward compatible with
66
+ future versions of rust by forbiding them to use these keywords.
67
+
68
+ > ** <sup >Lexer</sup >**
69
+ > KW_ABSTRACT : ` abstract `
70
+ > KW_ALIGNOF : ` alignof `
71
+ > KW_BECOME : ` become `
72
+ > KW_DO : ` do `
73
+ > KW_FINAL : ` final `
74
+ > KW_MACRO : ` macro `
75
+ > KW_OFFSETOF : ` offsetof `
76
+ > KW_OVERRIDE : ` override `
77
+ > KW_PRIV : ` priv `
78
+ > KW_PROC : ` proc `
79
+ > KW_PURE : ` pure `
80
+ > KW_SIZEOF : ` sizeof `
81
+ > KW_TYPEOF : ` typeof `
82
+ > KW_UNSIZED : ` unsized `
83
+ > KW_VIRTUAL : ` virtual `
84
+ > KW_YIELD : ` yield `
You can’t perform that action at this time.
0 commit comments