Rust has many reserved keywords like become
. But what will they do?
7 April, 2025
I found a page in the Rust reference that lists all of the currently reserved keywords:
priv
become
abstract
override
final
box
do
macro
typeof
unsized
virtual
yield
try
I am really curious what they will do. I did some research, compiling a list of rfcs which use these keywords with my own speculations mixed in:
priv
: Everything in Rust is already private by default1 except trait items, enum variants, and fields in enum variants. Perhaps at some point these can be made opt-in private.become
: Tail call optimization for recursive functions.abstract
,override
,final
: Was reserved for a possibility of adding “more efficient inheritance”2box
: Box patterns.do
: In the old days,do
was a way to invoke a function that takes a closure as a parameter such asdo task::spawn { println!("Hello, world!"); }
.2macro
: Declarative macros 2.0, which will bring many improvements over the current system – such as improved hygienetypeof
: Obtain the type of an expression so you can do something like:let x: typeof("a") = "hello"
.unsized
: Could be syntax sugar for!Sized
.virtual
: Rust used to have “virtual structs” which were implemented as a test, this lead to thevirtual
keyword. They were later removed, but the keyword was kept.yield
andgen
: Generator functions and blocks.try
: Local blocks which the?
operator can return from without returning from the function.
unsized
only makes sense as sugar for !Sized
but is this really necessary? Rust tries hard not to special case the standard library and just adding syntax for a built-in item seems like isn’t necessary. I didn’t find an RFC for it though so it could be used for more than that.
do
is used for the do yeet
in https://github.com/rust-lang/rust/issues/96373 but the syntax will change when its stabilized so I don’t count it.