Skip to content

Commit

Permalink
Merge pull request #963 from Havvy/remove-enum-variant-expr
Browse files Browse the repository at this point in the history
Remove enum variant expr
  • Loading branch information
ehuss committed Feb 15, 2021
2 parents 4cbbd87 + d91074b commit 6017cc6
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 67 deletions.
3 changes: 3 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ author = "The Rust Project Developers"
[output.html]
additional-css = ["theme/reference.css"]
git-repository-url = "https://github.com/rust-lang/reference/"

[output.html.redirect]
"/expressions/enum-variant-expr.html" = "struct-expr.html"
1 change: 0 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
- [Array and index expressions](expressions/array-expr.md)
- [Tuple and index expressions](expressions/tuple-expr.md)
- [Struct expressions](expressions/struct-expr.md)
- [Enum variant expressions](expressions/enum-variant-expr.md)
- [Call expressions](expressions/call-expr.md)
- [Method call expressions](expressions/method-call-expr.md)
- [Field access expressions](expressions/field-expr.md)
Expand Down
3 changes: 1 addition & 2 deletions src/attributes/type_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Non-exhaustive types cannot be constructed outside of the defining crate:

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

<!-- ignore: requires external crates -->
```rust,ignore
Expand Down Expand Up @@ -129,7 +129,6 @@ match message {

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

[_EnumerationVariantExpression_]: ../expressions/enum-variant-expr.md
[_MetaWord_]: ../attributes.md#meta-item-attribute-syntax
[_StructExpression_]: ../expressions/struct-expr.md
[_StructPattern_]: ../patterns.md#struct-patterns
Expand Down
2 changes: 0 additions & 2 deletions src/const_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ to be run.
* [Tuple expressions].
* [Array expressions].
* [Struct] expressions.
* [Enum variant] expressions.
* [Block expressions], including `unsafe` blocks.
* [let statements] and thus irrefutable [patterns], including mutable bindings
* [assignment expressions]
Expand Down Expand Up @@ -117,7 +116,6 @@ Conversely, the following are possible in a const function, but not in a const c
[dereference operator]: expressions/operator-expr.md#the-dereference-operator
[destructors]: destructors.md
[enum discriminants]: items/enumerations.md#custom-discriminant-values-for-fieldless-enumerations
[enum variant]: expressions/enum-variant-expr.md
[expression statements]: statements.md#expression-statements
[expressions]: expressions.md
[field]: expressions/field-expr.md
Expand Down
6 changes: 1 addition & 5 deletions src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
> &nbsp;&nbsp; &nbsp;&nbsp; | [_TupleExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_TupleIndexingExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_StructExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_EnumerationVariantExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_CallExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_MethodCallExpression_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | [_FieldExpression_]\
Expand Down Expand Up @@ -103,7 +102,6 @@ evaluate them conditionally as described on their respective pages.
* Tuple expression
* Tuple index expression
* Struct expression
* Enumeration variant expression
* Call expression
* Method call expression
* Field expression
Expand Down Expand Up @@ -259,7 +257,7 @@ a few specific cases:

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

[block expressions]: expressions/block-expr.md
[call expressions]: expressions/call-expr.md
[enum variant]: expressions/enum-variant-expr.md
[field]: expressions/field-expr.md
[functional update]: expressions/struct-expr.md#functional-update-syntax
[`if let`]: expressions/if-expr.md#if-let-expressions
Expand Down Expand Up @@ -329,7 +326,6 @@ They are never allowed before:
[_ComparisonExpression_]: expressions/operator-expr.md#comparison-operators
[_CompoundAssignmentExpression_]: expressions/operator-expr.md#compound-assignment-expressions
[_ContinueExpression_]: expressions/loop-expr.md#continue-expressions
[_EnumerationVariantExpression_]: expressions/enum-variant-expr.md
[_FieldExpression_]: expressions/field-expr.md
[_GroupedExpression_]: expressions/grouped-expr.md
[_IfExpression_]: expressions/if-expr.md#if-expressions
Expand Down
3 changes: 1 addition & 2 deletions src/expressions/block-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ let a = unsafe { an_unsafe_fn() };
* Loop bodies ([`loop`], [`while`], [`while let`], and [`for`]).
* Block expressions used as a [statement].
* Block expressions as elements of [array expressions], [tuple expressions],
[call expressions], and tuple-style [struct] and [enum variant] expressions.
[call expressions], and tuple-style [struct] expressions.
* A block expression as the tail expression of another block expression.
<!-- Keep list in sync with expressions.md -->

Expand All @@ -178,7 +178,6 @@ fn is_unix_platform() -> bool {
[`while`]: loop-expr.md#predicate-loops
[array expressions]: array-expr.md
[call expressions]: call-expr.md
[enum variant]: enum-variant-expr.md
[function]: ../items/functions.md
[inner attributes]: ../attributes.md
[method]: ../items/associated-items.md#methods
Expand Down
47 changes: 0 additions & 47 deletions src/expressions/enum-variant-expr.md

This file was deleted.

9 changes: 5 additions & 4 deletions src/expressions/struct-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
>
> _StructExprUnit_ : [_PathInExpression_]
A _struct expression_ creates a struct or union value.
It consists of a path to a [struct] or [union] item followed by the values for the fields of the item.
A *struct expression* creates a struct, enum, or union value.
It consists of a path to a [struct], [enum variant], or [union] item followed by the values for the fields of the item.
There are three forms of struct expressions: struct, tuple, and unit.

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

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

## Functional update syntax

A struct expression can terminate with the syntax `..` followed by an expression to denote a functional update.
A struct expression that constructs a value of a struct type can terminate with the syntax `..` followed by an expression to denote a functional update.
The expression following `..` (the base) must have the same struct type as the new struct type being formed.

The entire expression uses the given values for the fields that were specified and moves or copies the remaining fields from the base expression.
Expand Down Expand Up @@ -134,6 +134,7 @@ let b = Gamma{}; // Exact same value as `a`.
[_PathInExpression_]: ../paths.md#paths-in-expressions
[attributes on block expressions]: block-expr.md#attributes-on-block-expressions
[call expression]: call-expr.md
[enum variant]: ../items/enumerations.md
[if let]: if-expr.md#if-let-expressions
[if]: if-expr.md#if-expressions
[loop]: loop-expr.md
Expand Down
2 changes: 1 addition & 1 deletion src/items/enumerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
> _EnumItemDiscriminant_ :\
> &nbsp;&nbsp; `=` [_Expression_]
An *enumeration*, also referred to as *enum* is a simultaneous definition of a
An *enumeration*, also referred to as an *enum*, is a simultaneous definition of a
nominal [enumerated type] as well as a set of *constructors*, that can be used
to create or pattern-match values of the corresponding enumerated type.

Expand Down
5 changes: 2 additions & 3 deletions src/types/enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ An [`enum` item] declares both the type and a number of *variants*, each of
which is independently named and has the syntax of a struct, tuple struct or
unit-like struct.

New instances of an `enum` can be constructed in an [enumeration variant
expression].
New instances of an `enum` can be constructed with a [struct expression].

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

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

0 comments on commit 6017cc6

Please sign in to comment.