What will these reserved Rust keywords do? Theory and speculation
1 April, 2025
I found this page which lists all reserved keywords for Rust: https://doc.rust-lang.org/reference/keywords.html
I did research and compiled a list of speculations / rfcs that use these keywords:
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 privatebecome
: tail call optimization for recursive functions (https://github.com/rust-lang/rfcs/pull/3407)abstract
,override
,final
: Was reserved for a possibility of adding "more efficient inheritance"2box
: box patterns (https://github.com/rust-lang/rust/issues/29641)do
: In the old days,do
was a way to invoke a function that takes a closure as a parameter such asdo task::span { println!("Hello, world!"); }
.2macro
: declarative macros 2.0 (https://github.com/rust-lang/rust/issues/39412)typeof
: get the type of an expression so you can dolet x: typeof("a") = "hello"
unsized
: 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
(weak): generator functions and blocks (https://github.com/rust-lang/rust/issues/117078)try
: local blocks which the?
operator can return from without returning from the function (https://github.com/rust-lang/rust/issues/31436)
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