Skip to content

Commit 7fbc053

Browse files
committed
Fixes from review.
1 parent c4aa4da commit 7fbc053

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
@@ -63,11 +63,12 @@ opaque reference to this discriminant can be obtained with the
6363
[`mem::discriminant`] function.
6464

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

6869
A struct-like variant can be instantiated with a [struct expression].
69-
A tuple-like variant can be instantiated with a [call expression].
70-
A unit-like variant can be instantiated with a [path expression].
70+
A tuple-like variant can be instantiated with a [call expression] or a [struct expression].
71+
A unit-like variant can be instantiated with a [path expression] or a [struct expression].
7172
For example:
7273

7374
```rust
@@ -79,7 +80,9 @@ enum Examples {
7980

8081
use Examples::*; // Creates aliases to all variants.
8182
let x = UnitLike; // Path expression of the const item.
83+
let x = UnitLike {}; // Struct expression.
8284
let y = TupleLike(123); // Call expression.
85+
let y = TupleLike { 0: 123 }; // Struct expression using integer field names.
8386
let z = StructLike { value: 123 }; // Struct expression.
8487
```
8588

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
@@ -163,7 +163,8 @@ Braces can be nested, creating a tree of paths, where each grouping of segments
163163
use std::collections::{BTreeSet, hash_map::{self, HashMap}};
164164
```
165165

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

168169
> **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.
169170
@@ -205,8 +206,9 @@ fn main() {
205206
}
206207
```
207208

208-
> **Note**: `self` as the first segment of a `use` path has a different meaning from `self` inside braces.
209-
> See [`self`] in the paths chapter for more information no the meaning of a leading `self`.
209+
> **Note**: `self` may also be used as the first segment of a path.
210+
> 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.
211+
> See [`self`] in the paths chapter for more information on the meaning of a leading `self`.
210212
211213
## Glob imports
212214

@@ -232,7 +234,7 @@ mod foo {
232234
```
233235

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

238240
```rust

src/paths.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn bar() {
210210

211211
* In a [trait] definition, it refers to the type implementing the trait.
212212
* In an [implementation], it refers to the implementing type.
213-
When implementing a tuple or unit [struct], [enumeration], or [union], it also refers to the constructor in the [value namespace].
213+
When implementing a tuple or unit [struct], it also refers to the constructor in the [value namespace].
214214
* In the definition of a [struct], [enumeration], or [union], it refers to the defining type.
215215
The definition is not allowed to be infinitely recursive (there must be an indirection).
216216

0 commit comments

Comments
 (0)