Targets · Rust · Reserved words

Reserved words

Rust keeps a set of words for its own syntax, so a program cannot use them as names. When a Program name collides with one, the renderer appends a single underscore — fn becomes fn_ — so the program keeps the name it chose and the output still compiles. Because _ is illegal in a Program identifier, the escape can never collide with a name a program actually chose.

Contents

How a Program becomes Rust, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

The full list

Every word Rust reserves, with the identifier a colliding Program name is escaped to. The rule is uniform — append a single _:

Reserved wordRendered identifier
asas_
asyncasync_
awaitawait_
breakbreak_
constconst_
continuecontinue_
cratecrate_
dyndyn_
elseelse_
enumenum_
externextern_
falsefalse_
fnfn_
forfor_
ifif_
implimpl_
inin_
letlet_
looploop_
matchmatch_
modmod_
movemove_
mutmut_
pubpub_
refref_
returnreturn_
selfself_
SelfSelf_
staticstatic_
structstruct_
supersuper_
traittrait_
truetrue_
typetype_
unionunion_
unsafeunsafe_
useuse_
wherewhere_
whilewhile_
abstractabstract_
becomebecome_
boxbox_
dodo_
finalfinal_
macromacro_
overrideoverride_
privpriv_
typeoftypeof_
unsizedunsized_
virtualvirtual_
yieldyield_
trytry_