Skip to content

Commit f565ed2

Browse files
Fixes from review.
1 parent c99db24 commit f565ed2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/items/enumerations.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ enum Enum {
8282
```
8383

8484
Variant constructors are similar to [struct] definitions, and can be referenced by a path from the enumeration name, including in [use declarations].
85-
The constructors are defined in both the [type namespace] and [value namespace] within the enumeration.
85+
Each variant defines its type in the [type namespace], though that type cannot be used as a type specifier.
86+
Each variant also defines a constructor in the [value namespace].
8687

8788
A struct-like variant can be instantiated with a [struct expression].
88-
A tuple-like variant can be instantiated with a [call expression].
89-
A unit-like variant can be instantiated with a [path expression].
89+
A tuple-like variant can be instantiated with a [call expression] or a [struct expression].
90+
A unit-like variant can be instantiated with a [path expression] or a [struct expression].
9091
For example:
9192

9293
```rust
@@ -98,7 +99,9 @@ enum Examples {
9899

99100
use Examples::*; // Creates aliases to all variants.
100101
let x = UnitLike; // Path expression of the const item.
102+
let x = UnitLike {}; // Struct expression.
101103
let y = TupleLike(123); // Call expression.
104+
let y = TupleLike { 0: 123 }; // Struct expression using integer field names.
102105
let z = StructLike { value: 123 }; // Struct expression.
103106
```
104107

src/items/use-declarations.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A _use declaration_ creates one or more local name bindings synonymous with
1313
some other [path]. Usually a `use` declaration is used to shorten the path
1414
required to refer to a module item. These declarations may appear in [modules]
1515
and [blocks], usually at the top.
16-
A `use` declaration is also sometimes called an "import".
16+
A `use` declaration is also sometimes called an _import_ or if it is public it is a _re-export_.
1717

1818
[path]: ../paths.md
1919
[modules]: modules.md
@@ -165,7 +165,8 @@ Braces can be nested, creating a tree of paths, where each grouping of segments
165165
use std::collections::{BTreeSet, hash_map::{self, HashMap}};
166166
```
167167

168-
An empty brace does not import anything. `a::b::{}` is treated as `a::b::{self as _}` and `use {};` has no effect.
168+
An empty brace does not import anything, though the leading path is validated that it is accessible.
169+
<!-- This is slightly wrong, see https://github.com/rust-lang/rust/issues/61826 -->
169170

170171
> **Edition Differences**: In the 2015 edition, paths are relative to the crate root, so an import such as `use {foo, bar};` will import the names `foo` and `bar` from the crate root, whereas starting in 2018 those names are relative to the current scope.
171172
@@ -207,8 +208,9 @@ fn main() {
207208
}
208209
```
209210

210-
> **Note**: `self` as the first segment of a `use` path has a different meaning from `self` inside braces.
211-
> See [`self`] in the paths chapter for more information no the meaning of a leading `self`.
211+
> **Note**: `self` may also be used as the first segment of a path.
212+
> The usage of `self` as the first segment and inside a `use` brace is logically the same; it means the current module of the parent segment, or the current module if there is no parent segment.
213+
> See [`self`] in the paths chapter for more information on the meaning of a leading `self`.
212214
213215
## Glob imports
214216

@@ -234,7 +236,7 @@ mod foo {
234236
```
235237

236238
Items and named imports are allowed to shadow names from glob imports in the same [namespace].
237-
That is, if there is a name already defined by another item in the same namespace, the glob import will skip it.
239+
That is, if there is a name already defined by another item in the same namespace, the glob import will be shadowed.
238240
For example:
239241

240242
```rust

src/paths.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl S {
225225

226226
* In a [trait] definition, it refers to the type implementing the trait.
227227
* In an [implementation], it refers to the implementing type.
228-
When implementing a tuple or unit [struct], [enumeration], or [union], it also refers to the constructor in the [value namespace].
228+
When implementing a tuple or unit [struct], it also refers to the constructor in the [value namespace].
229229
* In the definition of a [struct], [enumeration], or [union], it refers to the defining type.
230230
The definition is not allowed to be infinitely recursive (there must be an indirection).
231231

0 commit comments

Comments
 (0)