Skip to content

Commit 084fa05

Browse files
authored
Merge pull request #442 from ehuss/kw-2018
Add 2018 edition keywords.
2 parents 6a5a823 + d8135e4 commit 084fa05

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/keywords.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ be used as the names of:
5757
> KW_WHERE : `where`\
5858
> KW_WHILE : `while`
5959
60+
The following keywords were added beginning in the 2018 edition.
61+
62+
> **<sup>Lexer 2018+</sup>**\
63+
> KW_DYN : `dyn`
64+
6065
## Reserved keywords
6166

6267
These keywords aren't used yet, but they are reserved for future use. They have
@@ -78,6 +83,13 @@ them to use these keywords.
7883
> KW_VIRTUAL : `virtual`\
7984
> KW_YIELD : `yield`
8085
86+
The following keywords are reserved beginning in the 2018 edition.
87+
88+
> **<sup>Lexer 2018+</sup>**\
89+
> KW_ASYNC : `async`\
90+
> KW_AWAIT : `await`\
91+
> KW_TRY : `try`
92+
8193
## Weak keywords
8294

8395
These keywords have special meaning only in certain contexts. For example, it
@@ -92,12 +104,16 @@ is possible to declare a variable or method with the name `union`.
92104
// error[E0262]: invalid lifetime parameter name: `'static`
93105
fn invalid_lifetime_parameter<'static>(s: &'static str) -> &'static str { s }
94106
```
95-
* `dyn` denotes a [trait object] and is a keyword when used in a type position
107+
* In the 2015 edition, [`dyn`] is a keyword when used in a type position
96108
followed by a path that does not start with `::`.
97109

110+
Beginning in the 2018 edition, `dyn` has been promoted to a strict keyword.
111+
98112
> **<sup>Lexer</sup>**\
99113
> KW_UNION : `union`\
100-
> KW_STATICLIFETIME : `'static`\
114+
> KW_STATICLIFETIME : `'static`
115+
>
116+
> **<sup>Lexer 2015</sup>**\
101117
> KW_DYN : `dyn`
102118
103119
[items]: items.html
@@ -110,4 +126,4 @@ is possible to declare a variable or method with the name `union`.
110126
[Crates]: crates-and-source-files.html
111127
[union]: items/unions.html
112128
[variants]: items/enumerations.html
113-
[trait object]: types.html#trait-objects
129+
[`dyn`]: types.html#trait-objects

src/types.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,14 @@ For example, given a trait `Trait`, the following are all trait objects:
676676
* `dyn 'static + Trait`.
677677
* `dyn (Trait)`
678678

679-
If the first bound of the trait object is a path that starts with `::`, then the
680-
`dyn` will be treated as a part of the path. The first path can be put in
681-
parenthesis to get around this. As such, if you want a trait object with the
682-
trait `::your_module::Trait`, you should write it as
683-
`dyn (::your_module::Trait)`.
679+
> **Edition Differences**: In the 2015 edition, if the first bound of the
680+
> trait object is a path that starts with `::`, then the `dyn` will be treated
681+
> as a part of the path. The first path can be put in parenthesis to get
682+
> around this. As such, if you want a trait object with the trait
683+
> `::your_module::Trait`, you should write it as `dyn (::your_module::Trait)`.
684+
>
685+
> Beginning in the 2018 edition, `dyn` is a true keyword and is not allowed in
686+
> paths, so the parentheses are not necessary.
684687
685688
> Note: For clarity, it is recommended to always use the `dyn` keyword on your
686689
> trait objects unless your codebase supports compiling with Rust 1.26 or lower.

0 commit comments

Comments
 (0)