Skip to content

Commit c9e8d08

Browse files
authored
Merge pull request #70 from matthewjasper/cleanup
Cleanup
2 parents 96e976d + 5694436 commit c9e8d08

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

src/expressions.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ The following expressions can create mutable lvalues:
7272
* [Temporary values](#temporary-lifetimes).
7373
* [Fields](#field-expressions), this evaluates the subexpression in a mutable
7474
lvalue context.
75-
* [Dereferenes](#the-dereference-operator) of a `*mut T` pointer.
75+
* [Dereferences](#the-dereference-operator) of a `*mut T` pointer.
7676
* Dereference of a variable, or field of a variable, with type `&mut T`. Note:
7777
this is an exception to the requirement for the next rule.
7878
* Dereferences of a type that implements `DerefMut`, this then requires that
7979
the value being dereferenced is evaluated is a mutable lvalue context.
8080
* [Indexing](#index-expressions) of a type that implements `DerefMut`, this
81-
then evalutes the value being indexed (but not the index) in mutable lvalue
81+
then evaluates the value being indexed (but not the index) in mutable lvalue
8282
context.
8383

8484
### Temporary lifetimes
@@ -168,7 +168,7 @@ also constant expressions:
168168
* [Paths](#path-expressions) to [functions](items.html#functions) and constants.
169169
Recursively defining constants is not allowed.
170170
* Paths to statics, so long as only their address, not their value, is used.
171-
This includes using their value indirectly through a compilicated expression.
171+
This includes using their value indirectly through a complicated expression.
172172
\*
173173
* [Tuple expressions](#tuple-expressions).
174174
* [Array expressions](#array-expressions).
@@ -267,7 +267,9 @@ the field values of a new instance of the struct. A field name can be any
267267
[identifier](identifiers.html), and is separated from its value expression by a
268268
colon. In the case of a tuple struct the field names are numbers corresponding
269269
to the position of the field. The numbers must be written in decimal,
270-
containing no underscores and with no leading zeros or integer suffix.
270+
containing no underscores and with no leading zeros or integer suffix. A value
271+
of a [union](items.html#unions) type can also be created using this syntax,
272+
except that it must specify exactly one field.
271273

272274
Struct expressions can't be used directly in the head of a [loop](#loops) or an
273275
[`if`](#if-expressions), [`if let`](#if-let-expressions) or
@@ -441,8 +443,8 @@ A _field expression_ consists of an expression followed by a single dot and an
441443
[identifier](identifiers.html), when not immediately followed by a
442444
parenthesized expression-list (the latter is always a [method call
443445
expression](#method-call-expressions)). A field expression denotes a field of a
444-
[struct](types.html#struct-types). To call a function stored in a struct
445-
parentheses are needed around the field expression
446+
[struct](types.html#struct-types) or [union](items.html#unions). To call a
447+
function stored in a struct parentheses are needed around the field expression
446448

447449
```rust,ignore
448450
mystruct.myfield;
@@ -452,9 +454,9 @@ mystruct.method(); // Method expression
452454
(mystruct.function_field)() // Call expression containing a field expression
453455
```
454456

455-
A field access is an [lvalue](expressions.html#lvalues-and-rvalues) referring to the value of
456-
that field. When the subexpression is [mutable](#mutability), the field
457-
expression is also mutable.
457+
A field access is an [lvalue](expressions.html#lvalues-and-rvalues) referring
458+
to the location of that field. When the subexpression is
459+
[mutable](#mutability), the field expression is also mutable.
458460

459461
Also, if the type of the expression to the left of the dot is a pointer, it is
460462
automatically dereferenced as many times as necessary to make the field access
@@ -482,7 +484,7 @@ let d: String = x.f3; // Move out of x.f3
482484
### Tuple indexing expressions
483485

484486
[Tuples](types.html#tuple-types) and [struct tuples](items.html#structs) can be
485-
indexed using the number corresponding to the possition of the field. The index
487+
indexed using the number corresponding to the position of the field. The index
486488
must be written as a [decimal literal](tokens.html#integer-literals) with no
487489
underscores or suffix. Tuple indexing expressions also differ from field
488490
expressions in that they can unambiguously be called as a function. In all

src/items.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ struct types, except that it must specify exactly one field:
591591

592592
```rust
593593
# union MyUnion { f1: u32, f2: f32 }
594-
594+
#
595595
let u = MyUnion { f1: 1 };
596596
```
597597

@@ -612,7 +612,7 @@ union fields have to be placed in `unsafe` blocks.
612612
```rust
613613
# union MyUnion { f1: u32, f2: f32 }
614614
# let u = MyUnion { f1: 1 };
615-
615+
#
616616
unsafe {
617617
let f = u.f1;
618618
}
@@ -624,7 +624,7 @@ so these writes don't have to be placed in `unsafe` blocks
624624
```rust
625625
# union MyUnion { f1: u32, f2: f32 }
626626
# let mut u = MyUnion { f1: 1 };
627-
627+
#
628628
u.f1 = 2;
629629
```
630630

@@ -639,7 +639,7 @@ to be placed in `unsafe` blocks as well.
639639

640640
```rust
641641
# union MyUnion { f1: u32, f2: f32 }
642-
642+
#
643643
fn f(u: MyUnion) {
644644
unsafe {
645645
match u {
@@ -715,12 +715,14 @@ More detailed specification for unions, including unstable bits, can be found in
715715

716716
## Constant items
717717

718-
A *constant item* is a named _constant value_ which is not associated with a
718+
A *constant item* is a named _[constant value]_ which is not associated with a
719719
specific memory location in the program. Constants are essentially inlined
720720
wherever they are used, meaning that they are copied directly into the relevant
721721
context when used. References to the same constant are not necessarily
722722
guaranteed to refer to the same memory address.
723723

724+
[constant value]: expressions.html#constant-expressions
725+
724726
Constant values must not have destructors, and otherwise permit most forms of
725727
data. Constants may refer to the address of other constants, in which case the
726728
address will have elided lifetimes where applicable, otherwise – in most cases –

src/linkage.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ The standard library in general strives to support both statically linked and
132132
dynamically linked C runtimes for targets as appropriate. For example the
133133
`x86_64-pc-windows-msvc` and `x86_64-unknown-linux-musl` targets typically come
134134
with both runtimes and the user selects which one they'd like. All targets in
135-
the compiler have a default mode of linking to the C runtime. Typicall targets
136-
linked dynamically by default, but there are exceptions which are static by
135+
the compiler have a default mode of linking to the C runtime. Typically targets
136+
are linked dynamically by default, but there are exceptions which are static by
137137
default such as:
138138

139139
* `arm-unknown-linux-musleabi`

src/tokens.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ grammar as double-quoted strings. Other tokens have exact rules given.
1212
A literal is an expression consisting of a single token, rather than a sequence
1313
of tokens, that immediately and directly denotes the value it evaluates to,
1414
rather than referring to it by name or some other evaluation rule. A literal is
15-
a form of constant expression, so is evaluated (primarily) at compile time.
15+
a form of [constant expression](expressions.html#constant-expressions), so is
16+
evaluated (primarily) at compile time.
1617

1718
### Examples
1819

0 commit comments

Comments
 (0)