Skip to content

Commit 3847261

Browse files
committed
Take another stab at defining "entity".
1 parent afb3464 commit 3847261

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

src/glossary.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ A dynamically sized type (DST) is a type without a statically known size or alig
6363

6464
### Entity
6565

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

6971
### Expression
7072

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

252254
[alignment]: type-layout.md#size-and-alignment
253255
[associated item]: #associated-item
254-
[attribute]: attributes.md
256+
[attributes]: attributes.md
255257
[*entity*]: names.md
256258
[enums]: items/enumerations.md
257-
[field]: expressions/field-expr.md
259+
[fields]: expressions/field-expr.md
258260
[free item]: #free-item
259-
[generic parameter]: items/generics.md
261+
[generic parameters]: items/generics.md
260262
[identifier]: identifiers.md
261263
[identifiers]: identifiers.md
262264
[implementation]: items/implementations.md
263265
[implementations]: items/implementations.md
264266
[inherent implementation]: items/implementations.md#inherent-implementations
265267
[item]: items.md
266-
[item]: items.md
268+
[items]: items.md
267269
[labels]: tokens.md#lifetimes-and-loop-labels
268270
[lifetime or loop label]: tokens.md#lifetimes-and-loop-labels
269-
[lifetime]: tokens.md#lifetimes-and-loop-labels
270-
[loop label]: tokens.md#lifetimes-and-loop-labels
271+
[lifetimes]: tokens.md#lifetimes-and-loop-labels
272+
[lints]: attributes/diagnostics.md#lint-check-attributes
273+
[loop labels]: tokens.md#lifetimes-and-loop-labels
271274
[method]: items/associated-items.md#methods
272275
[*Name resolution*]: names/name-resolution.md
273276
[*name*]: names.md
@@ -280,7 +283,7 @@ example of an uninhabited type is the [never type] `!`, or an enum with no varia
280283
[structs]: items/structs.md
281284
[trait objects]: types/trait-object.md
282285
[traits]: items/traits.md
283-
[type]: types.md
286+
[types]: types.md
284287
[undefined-behavior]: behavior-considered-undefined.md
285288
[unions]: items/unions.md
286-
[variable binding]: patterns.md
289+
[variable bindings]: patterns.md

src/names.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Names
22

3-
Entities declare a *name* to refer to that entity. Some entities are
4-
[explicitly declared](#explicit-entities) in the source code, and some are
5-
[implicitly declared](#implicit-entities) as part of the language or compiler
6-
extensions.
3+
An *entity* is a language construct that can be referred to in some way within
4+
the source program, usually via a [*path*]. Entities include [types], [items],
5+
[generic parameters], [variable bindings], [loop labels], [lifetimes],
6+
[fields], [attributes], and [lints].
77

8-
Entity names are valid within a [*scope*] — a region of source text where that
9-
name may be referenced.
8+
A *declaration* is a syntactical construct that can introduce a *name* to
9+
refer to an entity. Entity names are valid within a [*scope*] — a region of
10+
source text where that name may be referenced.
11+
12+
Some entities are [explicitly declared](#explicit-entities) in the source
13+
code, and some are [implicitly declared](#implicit-entities) as part of the
14+
language or compiler extensions.
1015

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

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

8085

8186
[*Name resolution*]: names/name-resolution.md
8287
[*namespaces*]: names/namespaces.md
88+
[*path*]: paths.md
8389
[*paths*]: paths.md
8490
[*scope*]: names/scopes.md
8591
[*visibility*]: visibility-and-privacy.md
8692
[`'static`]: keywords.md#weak-keywords
87-
[path qualifiers]: paths.md#path-qualifiers
8893
[`for`]: expressions/loop-expr.md#iterator-loops
8994
[`if let`]: expressions/if-expr.md#if-let-expressions
9095
[`let` statement]: statements.md#let-statements
@@ -105,6 +110,7 @@ to with certain [path qualifiers].
105110
[extern-prelude]: names/preludes.md#extern-prelude
106111
[External block items]: items/external-blocks.md
107112
[External crate declarations]: items/extern-crates.md
113+
[fields]: expressions/field-expr.md
108114
[floating-point types]: types/numeric.md#floating-point-types
109115
[Function declarations]: items/functions.md
110116
[function parameters]: items/functions.md#function-parameters
@@ -115,12 +121,14 @@ to with certain [path qualifiers].
115121
[Items]: items.md
116122
[Language prelude]: names/preludes.md#language-prelude
117123
[lifetimes-and-loop-labels]: tokens.md#lifetimes-and-loop-labels
124+
[lifetimes]: tokens.md#lifetimes-and-loop-labels
118125
[Lints]: attributes/diagnostics.md#lint-check-attributes
119126
[Loop labels]: expressions/loop-expr.md#loop-labels
120127
[Machine-dependent integer types]: types/numeric.md#machine-dependent-integer-types
121128
[macro invocations]: macros.md#macro-invocation
122129
[matcher metavariables]: macros-by-example.md#metavariables
123130
[Module declarations]: items/modules.md
131+
[path qualifiers]: paths.md#path-qualifiers
124132
[Standard library prelude]: names/preludes.md#standard-library-prelude
125133
[Static item declarations]: items/static-items.md
126134
[struct]: items/structs.md
@@ -129,5 +137,7 @@ to with certain [path qualifiers].
129137
[tool lint attributes]: attributes/diagnostics.md#tool-lint-attributes
130138
[Trait item declarations]: items/traits.md
131139
[Type aliases]: items/type-aliases.md
140+
[types]: types.md
132141
[union]: items/unions.md
133142
[Use declarations]: items/use-declarations.md
143+
[variable bindings]: patterns.md

0 commit comments

Comments
 (0)