Skip to content

Commit

Permalink
Merge pull request rust-lang#70 from matthewjasper/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
steveklabnik authored Jun 19, 2017
2 parents 96e976d + 5694436 commit c9e8d08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
22 changes: 12 additions & 10 deletions src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ The following expressions can create mutable lvalues:
* [Temporary values](#temporary-lifetimes).
* [Fields](#field-expressions), this evaluates the subexpression in a mutable
lvalue context.
* [Dereferenes](#the-dereference-operator) of a `*mut T` pointer.
* [Dereferences](#the-dereference-operator) of a `*mut T` pointer.
* Dereference of a variable, or field of a variable, with type `&mut T`. Note:
this is an exception to the requirement for the next rule.
* Dereferences of a type that implements `DerefMut`, this then requires that
the value being dereferenced is evaluated is a mutable lvalue context.
* [Indexing](#index-expressions) of a type that implements `DerefMut`, this
then evalutes the value being indexed (but not the index) in mutable lvalue
then evaluates the value being indexed (but not the index) in mutable lvalue
context.

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

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

```rust,ignore
mystruct.myfield;
Expand All @@ -452,9 +454,9 @@ mystruct.method(); // Method expression
(mystruct.function_field)() // Call expression containing a field expression
```

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

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

[Tuples](types.html#tuple-types) and [struct tuples](items.html#structs) can be
indexed using the number corresponding to the possition of the field. The index
indexed using the number corresponding to the position of the field. The index
must be written as a [decimal literal](tokens.html#integer-literals) with no
underscores or suffix. Tuple indexing expressions also differ from field
expressions in that they can unambiguously be called as a function. In all
Expand Down
12 changes: 7 additions & 5 deletions src/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ struct types, except that it must specify exactly one field:

```rust
# union MyUnion { f1: u32, f2: f32 }

#
let u = MyUnion { f1: 1 };
```

Expand All @@ -612,7 +612,7 @@ union fields have to be placed in `unsafe` blocks.
```rust
# union MyUnion { f1: u32, f2: f32 }
# let u = MyUnion { f1: 1 };

#
unsafe {
let f = u.f1;
}
Expand All @@ -624,7 +624,7 @@ so these writes don't have to be placed in `unsafe` blocks
```rust
# union MyUnion { f1: u32, f2: f32 }
# let mut u = MyUnion { f1: 1 };

#
u.f1 = 2;
```

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

```rust
# union MyUnion { f1: u32, f2: f32 }

#
fn f(u: MyUnion) {
unsafe {
match u {
Expand Down Expand Up @@ -715,12 +715,14 @@ More detailed specification for unions, including unstable bits, can be found in

## Constant items

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

[constant value]: expressions.html#constant-expressions

Constant values must not have destructors, and otherwise permit most forms of
data. Constants may refer to the address of other constants, in which case the
address will have elided lifetimes where applicable, otherwise – in most cases –
Expand Down
4 changes: 2 additions & 2 deletions src/linkage.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ The standard library in general strives to support both statically linked and
dynamically linked C runtimes for targets as appropriate. For example the
`x86_64-pc-windows-msvc` and `x86_64-unknown-linux-musl` targets typically come
with both runtimes and the user selects which one they'd like. All targets in
the compiler have a default mode of linking to the C runtime. Typicall targets
linked dynamically by default, but there are exceptions which are static by
the compiler have a default mode of linking to the C runtime. Typically targets
are linked dynamically by default, but there are exceptions which are static by
default such as:

* `arm-unknown-linux-musleabi`
Expand Down
3 changes: 2 additions & 1 deletion src/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ grammar as double-quoted strings. Other tokens have exact rules given.
A literal is an expression consisting of a single token, rather than a sequence
of tokens, that immediately and directly denotes the value it evaluates to,
rather than referring to it by name or some other evaluation rule. A literal is
a form of constant expression, so is evaluated (primarily) at compile time.
a form of [constant expression](expressions.html#constant-expressions), so is
evaluated (primarily) at compile time.

### Examples

Expand Down

0 comments on commit c9e8d08

Please sign in to comment.