Skip to content

Start documenting name resolution. #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Take another stab at defining "entity".
  • Loading branch information
ehuss committed Jan 18, 2021
commit 3847261a394242b00f6f0acf96ac9c186771345c
23 changes: 13 additions & 10 deletions src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ A dynamically sized type (DST) is a type without a statically known size or alig

### Entity

An [*entity*] is a [type], [item], [generic parameter], [variable binding],
[loop label], [lifetime], [field], or [attribute].
An [*entity*] is a language construct that can be referred to in some way
within the source program, usually via a [path][paths]. Entities include
[types], [items], [generic parameters], [variable bindings], [loop labels],
[lifetimes], [fields], [attributes], and [lints].

### Expression

Expand Down Expand Up @@ -251,23 +253,24 @@ example of an uninhabited type is the [never type] `!`, or an enum with no varia

[alignment]: type-layout.md#size-and-alignment
[associated item]: #associated-item
[attribute]: attributes.md
[attributes]: attributes.md
[*entity*]: names.md
[enums]: items/enumerations.md
[field]: expressions/field-expr.md
[fields]: expressions/field-expr.md
[free item]: #free-item
[generic parameter]: items/generics.md
[generic parameters]: items/generics.md
[identifier]: identifiers.md
[identifiers]: identifiers.md
[implementation]: items/implementations.md
[implementations]: items/implementations.md
[inherent implementation]: items/implementations.md#inherent-implementations
[item]: items.md
[item]: items.md
[items]: items.md
[labels]: tokens.md#lifetimes-and-loop-labels
[lifetime or loop label]: tokens.md#lifetimes-and-loop-labels
[lifetime]: tokens.md#lifetimes-and-loop-labels
[loop label]: tokens.md#lifetimes-and-loop-labels
[lifetimes]: tokens.md#lifetimes-and-loop-labels
[lints]: attributes/diagnostics.md#lint-check-attributes
[loop labels]: tokens.md#lifetimes-and-loop-labels
[method]: items/associated-items.md#methods
[*Name resolution*]: names/name-resolution.md
[*name*]: names.md
Expand All @@ -280,7 +283,7 @@ example of an uninhabited type is the [never type] `!`, or an enum with no varia
[structs]: items/structs.md
[trait objects]: types/trait-object.md
[traits]: items/traits.md
[type]: types.md
[types]: types.md
[undefined-behavior]: behavior-considered-undefined.md
[unions]: items/unions.md
[variable binding]: patterns.md
[variable bindings]: patterns.md
26 changes: 18 additions & 8 deletions src/names.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Names

Entities declare a *name* to refer to that entity. Some entities are
[explicitly declared](#explicit-entities) in the source code, and some are
[implicitly declared](#implicit-entities) as part of the language or compiler
extensions.
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].

Entity names are valid within a [*scope*] — a region of source text where that
name may be referenced.
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](#explicit-entities) in the source
code, and some are [implicitly declared](#implicit-entities) as part of the
language or compiler extensions.

[*Paths*] are used to refer to an entity, possibly in another scope. Lifetimes
and loop labels use a [dedicated syntax][lifetimes-and-loop-labels] using a
Expand Down Expand Up @@ -75,16 +80,16 @@ introduced by compiler options and extensions:
* The [`'static`] lifetime

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


[*Name resolution*]: names/name-resolution.md
[*namespaces*]: names/namespaces.md
[*path*]: paths.md
[*paths*]: paths.md
[*scope*]: names/scopes.md
[*visibility*]: visibility-and-privacy.md
[`'static`]: keywords.md#weak-keywords
[path qualifiers]: paths.md#path-qualifiers
[`for`]: expressions/loop-expr.md#iterator-loops
[`if let`]: expressions/if-expr.md#if-let-expressions
[`let` statement]: statements.md#let-statements
Expand All @@ -105,6 +110,7 @@ to with certain [path qualifiers].
[extern-prelude]: names/preludes.md#extern-prelude
[External block items]: items/external-blocks.md
[External crate declarations]: items/extern-crates.md
[fields]: expressions/field-expr.md
[floating-point types]: types/numeric.md#floating-point-types
[Function declarations]: items/functions.md
[function parameters]: items/functions.md#function-parameters
Expand All @@ -115,12 +121,14 @@ to with certain [path qualifiers].
[Items]: items.md
[Language prelude]: names/preludes.md#language-prelude
[lifetimes-and-loop-labels]: tokens.md#lifetimes-and-loop-labels
[lifetimes]: tokens.md#lifetimes-and-loop-labels
[Lints]: attributes/diagnostics.md#lint-check-attributes
[Loop labels]: expressions/loop-expr.md#loop-labels
[Machine-dependent integer types]: types/numeric.md#machine-dependent-integer-types
[macro invocations]: macros.md#macro-invocation
[matcher metavariables]: macros-by-example.md#metavariables
[Module declarations]: items/modules.md
[path qualifiers]: paths.md#path-qualifiers
[Standard library prelude]: names/preludes.md#standard-library-prelude
[Static item declarations]: items/static-items.md
[struct]: items/structs.md
Expand All @@ -129,5 +137,7 @@ to with certain [path qualifiers].
[tool lint attributes]: attributes/diagnostics.md#tool-lint-attributes
[Trait item declarations]: items/traits.md
[Type aliases]: items/type-aliases.md
[types]: types.md
[union]: items/unions.md
[Use declarations]: items/use-declarations.md
[variable bindings]: patterns.md