Names

An entity is a language construct that can be referred to in some way within the source program, usually via a path. Entities include types, items, generic parameters, variable bindings, loop labels, lifetimes, fields, attributes, and lints.

A declaration is a syntactical construct that can introduce a name to refer to an entity. Entity names are valid within a scope — a region of source text where that name may be referenced.

Some entities are explicitly declared in the source code, and some are implicitly declared as part of the language or compiler extensions.

Paths are used to refer to an entity, possibly in another module or type. Lifetimes and loop labels use a dedicated syntax using a leading quote.

Names are segregated into different namespaces, allowing entities in different namespaces to share the same name without conflict.

Name resolution is the compile-time process of tying paths, identifiers, and labels to entity declarations.

Access to certain names may be restricted based on their visibility.

Explicitly declared entities

Entities that explicitly introduce a name in the source code are:

Additionally, macro invocations and attributes can introduce names by expanding to one of the above items.

Implicitly declared entities

The following entities are implicitly defined by the language, or are introduced by compiler options and extensions:

Additionally, the crate root module does not have a name, but can be referred to with certain path qualifiers or aliases.