mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #25283 - steveklabnik:gh24999, r=alexcrichton
and remove references to the unit type, which no longer exists Fixes #24999
This commit is contained in:
commit
adf5b84394
@ -31,23 +31,27 @@ You may also be interested in the [grammar].
|
|||||||
|
|
||||||
## Unicode productions
|
## Unicode productions
|
||||||
|
|
||||||
A few productions in Rust's grammar permit Unicode code points outside the ASCII
|
A few productions in Rust's grammar permit Unicode code points outside the
|
||||||
range. We define these productions in terms of character properties specified
|
ASCII range. We define these productions in terms of character properties
|
||||||
in the Unicode standard, rather than in terms of ASCII-range code points. The
|
specified in the Unicode standard, rather than in terms of ASCII-range code
|
||||||
section [Special Unicode Productions](#special-unicode-productions) lists these
|
points. The grammar has a [Special Unicode Productions][unicodeproductions]
|
||||||
productions.
|
section that lists these productions.
|
||||||
|
|
||||||
|
[unicodeproductions]: grammar.html#special-unicode-productions
|
||||||
|
|
||||||
## String table productions
|
## String table productions
|
||||||
|
|
||||||
Some rules in the grammar — notably [unary
|
Some rules in the grammar — notably [unary
|
||||||
operators](#unary-operator-expressions), [binary
|
operators](#unary-operator-expressions), [binary
|
||||||
operators](#binary-operator-expressions), and [keywords](#keywords) — are
|
operators](#binary-operator-expressions), and [keywords][keywords] — are
|
||||||
given in a simplified form: as a listing of a table of unquoted, printable
|
given in a simplified form: as a listing of a table of unquoted, printable
|
||||||
whitespace-separated strings. These cases form a subset of the rules regarding
|
whitespace-separated strings. These cases form a subset of the rules regarding
|
||||||
the [token](#tokens) rule, and are assumed to be the result of a
|
the [token](#tokens) rule, and are assumed to be the result of a
|
||||||
lexical-analysis phase feeding the parser, driven by a DFA, operating over the
|
lexical-analysis phase feeding the parser, driven by a DFA, operating over the
|
||||||
disjunction of all such string table entries.
|
disjunction of all such string table entries.
|
||||||
|
|
||||||
|
[keywords]: grammar.html#keywords
|
||||||
|
|
||||||
When such a string enclosed in double-quotes (`"`) occurs inside the grammar,
|
When such a string enclosed in double-quotes (`"`) occurs inside the grammar,
|
||||||
it is an implicit reference to a single member of such a string table
|
it is an implicit reference to a single member of such a string table
|
||||||
production. See [tokens](#tokens) for more information.
|
production. See [tokens](#tokens) for more information.
|
||||||
@ -75,7 +79,7 @@ An identifier is any nonempty Unicode[^non_ascii_idents] string of the following
|
|||||||
- The first character has property `XID_start`
|
- The first character has property `XID_start`
|
||||||
- The remaining characters have property `XID_continue`
|
- The remaining characters have property `XID_continue`
|
||||||
|
|
||||||
that does _not_ occur in the set of [keywords](#keywords).
|
that does _not_ occur in the set of [keywords][keywords].
|
||||||
|
|
||||||
> **Note**: `XID_start` and `XID_continue` as character properties cover the
|
> **Note**: `XID_start` and `XID_continue` as character properties cover the
|
||||||
> character ranges used to form the more familiar C and Java language-family
|
> character ranges used to form the more familiar C and Java language-family
|
||||||
@ -401,7 +405,7 @@ Symbols are a general class of printable [token](#tokens) that play structural
|
|||||||
roles in a variety of grammar productions. They are catalogued here for
|
roles in a variety of grammar productions. They are catalogued here for
|
||||||
completeness as the set of remaining miscellaneous printable tokens that do not
|
completeness as the set of remaining miscellaneous printable tokens that do not
|
||||||
otherwise appear as [unary operators](#unary-operator-expressions), [binary
|
otherwise appear as [unary operators](#unary-operator-expressions), [binary
|
||||||
operators](#binary-operator-expressions), or [keywords](#keywords).
|
operators](#binary-operator-expressions), or [keywords][keywords].
|
||||||
|
|
||||||
|
|
||||||
## Paths
|
## Paths
|
||||||
@ -611,7 +615,7 @@ module needs its own source file: [module definitions](#modules) can be nested
|
|||||||
within one file.
|
within one file.
|
||||||
|
|
||||||
Each source file contains a sequence of zero or more `item` definitions, and
|
Each source file contains a sequence of zero or more `item` definitions, and
|
||||||
may optionally begin with any number of [attributes](#Items and attributes)
|
may optionally begin with any number of [attributes](#items-and-attributes)
|
||||||
that apply to the containing module, most of which influence the behavior of
|
that apply to the containing module, most of which influence the behavior of
|
||||||
the compiler. The anonymous crate module can have additional attributes that
|
the compiler. The anonymous crate module can have additional attributes that
|
||||||
apply to the crate as a whole.
|
apply to the crate as a whole.
|
||||||
@ -653,7 +657,7 @@ There are several kinds of item:
|
|||||||
* [`use` declarations](#use-declarations)
|
* [`use` declarations](#use-declarations)
|
||||||
* [modules](#modules)
|
* [modules](#modules)
|
||||||
* [functions](#functions)
|
* [functions](#functions)
|
||||||
* [type aliases](#type-aliases)
|
* [type definitions](grammar.html#type-definitions)
|
||||||
* [structures](#structures)
|
* [structures](#structures)
|
||||||
* [enumerations](#enumerations)
|
* [enumerations](#enumerations)
|
||||||
* [constant items](#constant-items)
|
* [constant items](#constant-items)
|
||||||
@ -773,7 +777,7 @@ extern crate std as ruststd; // linking to 'std' under another name
|
|||||||
A _use declaration_ creates one or more local name bindings synonymous with
|
A _use declaration_ creates one or more local name bindings synonymous with
|
||||||
some other [path](#paths). Usually a `use` declaration is used to shorten the
|
some other [path](#paths). Usually a `use` declaration is used to shorten the
|
||||||
path required to refer to a module item. These declarations may appear at the
|
path required to refer to a module item. These declarations may appear at the
|
||||||
top of [modules](#modules) and [blocks](#blocks).
|
top of [modules](#modules) and [blocks](grammar.html#block-expressions).
|
||||||
|
|
||||||
> **Note**: Unlike in many languages,
|
> **Note**: Unlike in many languages,
|
||||||
> `use` declarations in Rust do *not* declare linkage dependency with external crates.
|
> `use` declarations in Rust do *not* declare linkage dependency with external crates.
|
||||||
@ -1144,9 +1148,7 @@ let px: i32 = match p { Point(x, _) => x };
|
|||||||
```
|
```
|
||||||
|
|
||||||
A _unit-like struct_ is a structure without any fields, defined by leaving off
|
A _unit-like struct_ is a structure without any fields, defined by leaving off
|
||||||
the list of fields entirely. Such types will have a single value, just like
|
the list of fields entirely. Such types will have a single value. For example:
|
||||||
the [unit value `()`](#unit-and-boolean-literals) of the unit type. For
|
|
||||||
example:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
struct Cookie;
|
struct Cookie;
|
||||||
@ -2436,11 +2438,6 @@ comma:
|
|||||||
(0); // zero in parentheses
|
(0); // zero in parentheses
|
||||||
```
|
```
|
||||||
|
|
||||||
### Unit expressions
|
|
||||||
|
|
||||||
The expression `()` denotes the _unit value_, the only value of the type with
|
|
||||||
the same name.
|
|
||||||
|
|
||||||
### Structure expressions
|
### Structure expressions
|
||||||
|
|
||||||
There are several forms of structure expressions. A _structure expression_
|
There are several forms of structure expressions. A _structure expression_
|
||||||
@ -3281,7 +3278,7 @@ constructor or `struct` field may refer, directly or indirectly, to the
|
|||||||
enclosing `enum` or `struct` type itself. Such recursion has restrictions:
|
enclosing `enum` or `struct` type itself. Such recursion has restrictions:
|
||||||
|
|
||||||
* Recursive types must include a nominal type in the recursion
|
* Recursive types must include a nominal type in the recursion
|
||||||
(not mere [type definitions](#type-definitions),
|
(not mere [type definitions](grammar.html#type-definitions),
|
||||||
or other structural types such as [arrays](#array,-and-slice-types) or [tuples](#tuple-types)).
|
or other structural types such as [arrays](#array,-and-slice-types) or [tuples](#tuple-types)).
|
||||||
* A recursive `enum` item must have at least one non-recursive constructor
|
* A recursive `enum` item must have at least one non-recursive constructor
|
||||||
(in order to give the recursion a basis case).
|
(in order to give the recursion a basis case).
|
||||||
|
Loading…
Reference in New Issue
Block a user