r[lex.keywords]

Keywords

Rust divides keywords into three categories:

r[lex.keywords.strict]

Strict keywords

r[lex.keywords.strict.intro] These keywords can only be used in their correct contexts. They cannot be used as the names of:

r[lex.keywords.strict.list] The following keywords are in all editions:

r[lex.keywords.strict.edition2018] The following keywords were added beginning in the 2018 edition.

r[lex.keywords.reserved]

Reserved keywords

r[lex.keywords.reserved.intro] These keywords aren't used yet, but they are reserved for future use. They have the same restrictions as strict keywords. The reasoning behind this is to make current programs forward compatible with future versions of Rust by forbidding them to use these keywords.

r[lex.keywords.reserved.list]

r[lex.keywords.reserved.edition2018] The following keywords are reserved beginning in the 2018 edition.

r[lex.keywords.reserved.edition2024] The following keywords are reserved beginning in the 2024 edition.

r[lex.keywords.weak]

Weak keywords

r[lex.keywords.weak.intro] These keywords have special meaning only in certain contexts. For example, it is possible to declare a variable or method with the name union.

r[lex.keywords.weak.macro_rules]

r[lex.keywords.weak.union]

r[lex.keywords.weak.lifetime-static]

r[lex.keywords.weak.safe]

r[lex.keywords.weak.raw]

r[lex.keywords.weak.dyn.edition2018]

[!EDITION-2018] In the 2015 edition, dyn is a keyword when used in a type position followed by a path that does not start with :: or <, a lifetime, a question mark, a for keyword or an opening parenthesis.

Beginning in the 2018 edition, dyn has been promoted to a strict keyword.