-
Notifications
You must be signed in to change notification settings - Fork 533
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
Changes from 4 commits
eabdf09
c7f5648
afb3464
3847261
0ce54e6
10da84b
a989af0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,13 @@ through a mechanism called ‘trait objects’. | |
|
||
A dynamically sized type (DST) is a type without a statically known size or alignment. | ||
|
||
### Entity | ||
|
||
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 | ||
|
||
An expression is a combination of values, constants, variables, operators | ||
|
@@ -123,6 +130,25 @@ This is not affected by applied type arguments. `struct Foo` is considered local | |
`Vec<Foo>` is not. `LocalType<ForeignType>` is local. Type aliases do not | ||
affect locality. | ||
|
||
### Name | ||
|
||
A [*name*] is an [identifier] or [lifetime or loop label] that refers to an | ||
[entity](#entity). A *name binding* is when an entity declaration introduces | ||
an identifier or label associated with that entity. [Paths], | ||
identifiers, and labels are used to refer to an entity. | ||
|
||
### Name resolution | ||
|
||
[*Name resolution*] is the compile-time process of tying [paths], | ||
[identifiers], and [labels] to [entity](#entity) declarations. | ||
|
||
### Namespace | ||
|
||
A [*namespace*] is a set of [names](#name) where each name unambiguously | ||
refers to a specific [entity](#entity). Namespaces are organized in a | ||
hierarchy, where each level of the hierarchy has its own collection of named | ||
entities. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is what is called "scope" in the compiler (https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/lib.rs#L102-L115)? ("Scope" in the compiler is also overloaded and used for other things.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok, it's not a "scope", but the wording is confusing.
This is plain indecipherable.
And this should somehow highlight that the hierarchies exist inside the namespaces, and not between them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I'm struggling to define it clearly. Lexicography is not my strong suit. I took another stab at it. I suspect this will receive updates and clarifications once I start working on the "scopes" chapter. |
||
|
||
### Nominal types | ||
|
||
Types that can be referred to by a path directly. Specifically [enums], | ||
|
@@ -133,11 +159,22 @@ Types that can be referred to by a path directly. Specifically [enums], | |
[Traits] that can be used as [trait objects]. Only traits that follow specific | ||
[rules][object safety] are object safe. | ||
|
||
### Path | ||
|
||
A [*path*] is a sequence of one or more path segments used to refer to an | ||
[entity](#entity) in the current scope or other levels of a | ||
[namespace](#namespace) hierarchy. | ||
|
||
### Prelude | ||
|
||
Prelude, or The Rust Prelude, is a small collection of items - mostly traits - that are | ||
imported into every module of every crate. The traits in the prelude are pervasive. | ||
|
||
### Scope | ||
|
||
A [*scope*] is the region of source text where a named [entity](#entity) may | ||
be referenced with that name. | ||
|
||
### Scrutinee | ||
|
||
A scrutinee is the expression that is matched on in `match` expressions and | ||
|
@@ -216,17 +253,37 @@ 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 | ||
[attributes]: attributes.md | ||
[*entity*]: names.md | ||
[enums]: items/enumerations.md | ||
[fields]: expressions/field-expr.md | ||
[free item]: #free-item | ||
[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 | ||
[items]: items.md | ||
[labels]: tokens.md#lifetimes-and-loop-labels | ||
[lifetime or 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 | ||
[*namespace*]: names/namespaces.md | ||
[never type]: types/never.md | ||
[object safety]: items/traits.md#object-safety | ||
[*path*]: paths.md | ||
[Paths]: paths.md | ||
[*scope*]: names/scopes.md | ||
[structs]: items/structs.md | ||
[trait objects]: types/trait-object.md | ||
[traits]: items/traits.md | ||
[types]: types.md | ||
[undefined-behavior]: behavior-considered-undefined.md | ||
[unions]: items/unions.md | ||
[variable bindings]: patterns.md |
Uh oh!
There was an error while loading. Please reload this page.