Skip to content

Commit d8cbe4e

Browse files
committed
Remove enum variant expression page
It is quite redundant with the (IMO badly named) struct expression. Perhaps we should rename it to something else? "Named value expression"?
1 parent 4cbbd87 commit d8cbe4e

File tree

9 files changed

+12
-67
lines changed

9 files changed

+12
-67
lines changed

src/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
- [Array and index expressions](expressions/array-expr.md)
5757
- [Tuple and index expressions](expressions/tuple-expr.md)
5858
- [Struct expressions](expressions/struct-expr.md)
59-
- [Enum variant expressions](expressions/enum-variant-expr.md)
6059
- [Call expressions](expressions/call-expr.md)
6160
- [Method call expressions](expressions/method-call-expr.md)
6261
- [Field access expressions](expressions/field-expr.md)

src/attributes/type_system.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Non-exhaustive types cannot be constructed outside of the defining crate:
6464

6565
- Non-exhaustive variants ([`struct`][struct] or [`enum` variant][enum]) cannot be constructed
6666
with a [_StructExpression_] \(including with [functional update syntax]).
67-
- [`enum`][enum] instances can be constructed in an [_EnumerationVariantExpression_].
67+
- [`enum`][enum] instances can be constructed.
6868

6969
<!-- ignore: requires external crates -->
7070
```rust,ignore
@@ -129,7 +129,6 @@ match message {
129129

130130
Non-exhaustive types are always considered inhabited in downstream crates.
131131

132-
[_EnumerationVariantExpression_]: ../expressions/enum-variant-expr.md
133132
[_MetaWord_]: ../attributes.md#meta-item-attribute-syntax
134133
[_StructExpression_]: ../expressions/struct-expr.md
135134
[_StructPattern_]: ../patterns.md#struct-patterns

src/const_eval.md

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ to be run.
2727
* [Tuple expressions].
2828
* [Array expressions].
2929
* [Struct] expressions.
30-
* [Enum variant] expressions.
3130
* [Block expressions], including `unsafe` blocks.
3231
* [let statements] and thus irrefutable [patterns], including mutable bindings
3332
* [assignment expressions]
@@ -117,7 +116,6 @@ Conversely, the following are possible in a const function, but not in a const c
117116
[dereference operator]: expressions/operator-expr.md#the-dereference-operator
118117
[destructors]: destructors.md
119118
[enum discriminants]: items/enumerations.md#custom-discriminant-values-for-fieldless-enumerations
120-
[enum variant]: expressions/enum-variant-expr.md
121119
[expression statements]: statements.md#expression-statements
122120
[expressions]: expressions.md
123121
[field]: expressions/field-expr.md

src/expressions.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
> &nbsp;&nbsp; &nbsp;&nbsp; | [_TupleExpression_]\
1919
> &nbsp;&nbsp; &nbsp;&nbsp; | [_TupleIndexingExpression_]\
2020
> &nbsp;&nbsp; &nbsp;&nbsp; | [_StructExpression_]\
21-
> &nbsp;&nbsp; &nbsp;&nbsp; | [_EnumerationVariantExpression_]\
2221
> &nbsp;&nbsp; &nbsp;&nbsp; | [_CallExpression_]\
2322
> &nbsp;&nbsp; &nbsp;&nbsp; | [_MethodCallExpression_]\
2423
> &nbsp;&nbsp; &nbsp;&nbsp; | [_FieldExpression_]\
@@ -103,7 +102,6 @@ evaluate them conditionally as described on their respective pages.
103102
* Tuple expression
104103
* Tuple index expression
105104
* Struct expression
106-
* Enumeration variant expression
107105
* Call expression
108106
* Method call expression
109107
* Field expression
@@ -259,7 +257,7 @@ a few specific cases:
259257

260258
* Before an expression used as a [statement].
261259
* Elements of [array expressions], [tuple expressions], [call expressions],
262-
and tuple-style [struct] and [enum variant] expressions.
260+
and tuple-style [struct] expressions.
263261
<!--
264262
These were likely stabilized inadvertently.
265263
See https://github.com/rust-lang/rust/issues/32796 and
@@ -277,7 +275,6 @@ They are never allowed before:
277275

278276
[block expressions]: expressions/block-expr.md
279277
[call expressions]: expressions/call-expr.md
280-
[enum variant]: expressions/enum-variant-expr.md
281278
[field]: expressions/field-expr.md
282279
[functional update]: expressions/struct-expr.md#functional-update-syntax
283280
[`if let`]: expressions/if-expr.md#if-let-expressions
@@ -329,7 +326,6 @@ They are never allowed before:
329326
[_ComparisonExpression_]: expressions/operator-expr.md#comparison-operators
330327
[_CompoundAssignmentExpression_]: expressions/operator-expr.md#compound-assignment-expressions
331328
[_ContinueExpression_]: expressions/loop-expr.md#continue-expressions
332-
[_EnumerationVariantExpression_]: expressions/enum-variant-expr.md
333329
[_FieldExpression_]: expressions/field-expr.md
334330
[_GroupedExpression_]: expressions/grouped-expr.md
335331
[_IfExpression_]: expressions/if-expr.md#if-expressions

src/expressions/block-expr.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let a = unsafe { an_unsafe_fn() };
153153
* Loop bodies ([`loop`], [`while`], [`while let`], and [`for`]).
154154
* Block expressions used as a [statement].
155155
* Block expressions as elements of [array expressions], [tuple expressions],
156-
[call expressions], and tuple-style [struct] and [enum variant] expressions.
156+
[call expressions], and tuple-style [struct] expressions.
157157
* A block expression as the tail expression of another block expression.
158158
<!-- Keep list in sync with expressions.md -->
159159

@@ -178,7 +178,6 @@ fn is_unix_platform() -> bool {
178178
[`while`]: loop-expr.md#predicate-loops
179179
[array expressions]: array-expr.md
180180
[call expressions]: call-expr.md
181-
[enum variant]: enum-variant-expr.md
182181
[function]: ../items/functions.md
183182
[inner attributes]: ../attributes.md
184183
[method]: ../items/associated-items.md#methods

src/expressions/enum-variant-expr.md

-47
This file was deleted.

src/expressions/struct-expr.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
>
2828
> _StructExprUnit_ : [_PathInExpression_]
2929
30-
A _struct expression_ creates a struct or union value.
31-
It consists of a path to a [struct] or [union] item followed by the values for the fields of the item.
30+
A *struct expression* creates a struct, enum, or union value.
31+
It consists of a path to a [struct], [enum], or [union] item followed by the values for the fields of the item.
3232
There are three forms of struct expressions: struct, tuple, and unit.
3333

3434
The following are examples of struct expressions:
@@ -52,7 +52,7 @@ some_fn::<Cookie>(Cookie);
5252
A struct expression with fields enclosed in curly braces allows you to specify the value for each individual field in any order.
5353
The field name is separated from its value with a colon.
5454

55-
A value of a [union] type can also be created using this syntax, except that it must specify exactly one field.
55+
A value of a [union] type can only be created using this syntax, and it must specify exactly one field.
5656

5757
## Functional update syntax
5858

@@ -101,7 +101,8 @@ Point3d { x, y: y_value, z };
101101
## Tuple struct expression
102102

103103
A struct expression with fields enclosed in parentheses constructs a tuple struct.
104-
Though it is listed here as a specific expression for completeness, it is equivalent to a [call expression] to the tuple struct's constructor. For example:
104+
Though it is listed here as a specific expression for completeness, it is equivalent to a [call expression] to the tuple struct's constructor. For example: <!--
105+
This is false. Example: Position(0, ..other_position) -->
105106

106107
```rust
107108
struct Position(i32, i32, i32);
@@ -134,6 +135,7 @@ let b = Gamma{}; // Exact same value as `a`.
134135
[_PathInExpression_]: ../paths.md#paths-in-expressions
135136
[attributes on block expressions]: block-expr.md#attributes-on-block-expressions
136137
[call expression]: call-expr.md
138+
[enum]: ../items/enumerations.md
137139
[if let]: if-expr.md#if-let-expressions
138140
[if]: if-expr.md#if-expressions
139141
[loop]: loop-expr.md

src/items/enumerations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
> _EnumItemDiscriminant_ :\
2626
> &nbsp;&nbsp; `=` [_Expression_]
2727
28-
An *enumeration*, also referred to as *enum* is a simultaneous definition of a
28+
An *enumeration*, also referred to as an *enum*, is a simultaneous definition of a
2929
nominal [enumerated type] as well as a set of *constructors*, that can be used
3030
to create or pattern-match values of the corresponding enumerated type.
3131

src/types/enum.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ An [`enum` item] declares both the type and a number of *variants*, each of
77
which is independently named and has the syntax of a struct, tuple struct or
88
unit-like struct.
99

10-
New instances of an `enum` can be constructed in an [enumeration variant
11-
expression].
10+
New instances of an `enum` can be constructed with a [struct expression].
1211

1312
Any `enum` value consumes as much memory as the largest variant for its
1413
corresponding `enum` type, as well as the size needed to store a discriminant.
@@ -20,4 +19,4 @@ named reference to an [`enum` item].
2019
ML, or a *pick ADT* in Limbo.
2120

2221
[`enum` item]: ../items/enumerations.md
23-
[enumeration variant expression]: ../expressions/enum-variant-expr.md
22+
[struct expression]: ../expressions/struct-expr.md

0 commit comments

Comments
 (0)