Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
book
*~
.*.sw*
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ title = "The Rust Reference"
author = "The Rust Project Developers"

[output.html]
additional-css = ["theme/reference.css"]

additional-css = ["src/theme/reference.css"]
40 changes: 20 additions & 20 deletions src/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,30 +473,30 @@ impl<T: PartialEq> PartialEq for Foo<T> {
You can implement `derive` for your own traits through [procedural macros].

[Doc comments]: comments.html#doc-comments
[ECMA-334]: https://www.ecma-international.org/publications/standards/Ecma-334.htm
[ECMA-335]: https://www.ecma-international.org/publications/standards/Ecma-335.htm
[The Rustdoc Book]: ../rustdoc/the-doc-attribute.html
[procedural macros]: procedural-macros.html
[struct]: items/structs.html
[enum]: items/enumerations.html
[union]: items/unions.html
[functions]: items/functions.html
[expression]: expressions.html
[expression statement]: statements.html#expression-statements
[call expression]: expressions/call-expr.html
[`Drop`]: special-types-and-traits.html#drop
[block expression]: expressions/block-expr.html
[block expressions]: expressions/block-expr.html
[`Drop`]: special-types-and-traits.html#drop
[let statement]: statements.html#let-statements
[unstable book plugin]: ../unstable-book/language-features/plugin.html#lint-plugins
[zero-variant enum]: items/enumerations.html#zero-variant-enums
[ECMA-334]: https://www.ecma-international.org/publications/standards/Ecma-334.htm
[ECMA-335]: https://www.ecma-international.org/publications/standards/Ecma-335.htm
[item declarations]: items.html
[call expression]: expressions/call-expr.html
[conditional compilation]: conditional-compilation.html
[enum]: items/enumerations.html
[expression statement]: statements.html#expression-statements
[expression]: expressions.html
[external blocks]: items/external-blocks.html
[functions]: items/functions.html
[generics]: items/generics.html
[implementations]: items/implementations.html
[item declarations]: items.html
[items]: items.html
[let statement]: statements.html#let-statements
[match expressions]: expressions/match-expr.html
[modules]: items/modules.html
[procedural macros]: procedural-macros.html
[statements]: statements.html
[match expressions]: expressions/match-expr.html
[external blocks]: items/external-blocks.html
[items]: items.html
[conditional compilation]: conditional-compilation.html
[trait]: items/traits.html
[struct]: items/structs.html
[trait]: items/traits.html
[union]: items/unions.html
[unstable book plugin]: ../unstable-book/language-features/plugin.html#lint-plugins
[zero-variant enum]: items/enumerations.html#zero-variant-enums
10 changes: 5 additions & 5 deletions src/behavior-considered-undefined.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ code.
* A value in a `char` which is a surrogate or above `char::MAX`.
* Non-UTF-8 byte sequences in a `str`.

[noalias]: http://llvm.org/docs/LangRef.html#noalias
[pointer aliasing rules]: http://llvm.org/docs/LangRef.html#pointer-aliasing-rules
[undef]: http://llvm.org/docs/LangRef.html#undefined-values
[`offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.offset
[`std::ptr::copy_nonoverlapping_memory`]: https://doc.rust-lang.org/std/ptr/fn.copy_nonoverlapping.html
[`UnsafeCell<U>`]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
[`offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.offset
[`read_unaligned`]: https://doc.rust-lang.org/std/ptr/fn.read_unaligned.html
[`std::ptr::copy_nonoverlapping_memory`]: https://doc.rust-lang.org/std/ptr/fn.copy_nonoverlapping.html
[`write_unaligned`]: https://doc.rust-lang.org/std/ptr/fn.write_unaligned.html
[Rustonomicon]: ../nomicon/index.html
[noalias]: http://llvm.org/docs/LangRef.html#noalias
[pointer aliasing rules]: http://llvm.org/docs/LangRef.html#pointer-aliasing-rules
[undef]: http://llvm.org/docs/LangRef.html#undefined-values
18 changes: 9 additions & 9 deletions src/crates-and-source-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

> **<sup>Lexer</sup>**\
> UTF8BOM : `\uFEFF`\
> SHEBANG : `#!` ~[`[` `\n`] ~`\n`<sup>*</sup>
> SHEBANG : `#!` ~[`[` `\n`] ~`\n`<sup>\*</sup>


> Note: Although Rust, like any other language, can be implemented by an
Expand Down Expand Up @@ -78,11 +78,11 @@ type must be one of the following:
> Note: The implementation of which return types are allowed is determined by
> the unstable [`Termination`] trait.

The optional [_UTF8 byte order mark_] (UTF8BOM production) indicates that the
The optional [_UTF8 byte order mark_] \(UTF8BOM production) indicates that the
file is encoded in UTF8. It can only occur at the beginning of the file and
is ignored by the compiler.

A source file can have a [_shebang_] (SHEBANG production), which indicates
A source file can have a [_shebang_] \(SHEBANG production), which indicates
to the operating system what program to use to execute this file. It serves
essentially to treat the source file as an executable script. The shebang
can only occur at the beginning of the file (but after the optional
Expand All @@ -104,15 +104,15 @@ fn main() {
ECMA-335 CLI model, a *library* in the SML/NJ Compilation Manager, a *unit*
in the Owens and Flatt module system, or a *configuration* in Mesa.

[module]: items/modules.html
[module path]: paths.html
[attributes]: attributes.html
[unit]: types.html#tuple-types
[_InnerAttribute_]: attributes.html
[_Item_]: items.html
[_shebang_]: https://en.wikipedia.org/wiki/Shebang_(Unix)
[_utf8 byte order mark_]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
[function]: items/functions.html
[`Termination`]: ../std/process/trait.Termination.html
[where clauses]: items/generics.html#where-clauses
[attributes]: attributes.html
[function]: items/functions.html
[module path]: paths.html
[module]: items/modules.html
[trait or lifetime bounds]: trait-bounds.html
[unit]: types.html#tuple-types
[where clauses]: items/generics.html#where-clauses
22 changes: 11 additions & 11 deletions src/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ Not running destructors in Rust is safe even if it has a type that isn't
`'static`. [`std::mem::ManuallyDrop`] provides a wrapper to prevent a
variable or field from being dropped automatically.

[initialized]: glossary.html#initialized
[variable]: variables.html
[temporary]: expressions.html#temporary-lifetimes
[Assignment]: expressions/operator-expr.html#assignment-expressions
[`std::ops::Drop::drop`]: ../std/ops/trait.Drop.html
[RFC 1857]: https://github.com/rust-lang/rfcs/blob/master/text/1857-stabilize-drop-order.md
[struct]: types.html#struct-types
[tuple]: types.html#tuple-types
[enum variant]: types.html#enumerated-types
[array]: types.html#array-and-slice-types
[closure]: types.html#closure-types
[Trait objects]: types.html#trait-objects
[`std::ptr::drop_in_place`]: ../std/ptr/fn.drop_in_place.html
[`std::mem::forget`]: ../std/mem/fn.forget.html
[`std::mem::ManuallyDrop`]: ../std/mem/struct.ManuallyDrop.html
[`std::mem::forget`]: ../std/mem/fn.forget.html
[`std::ops::Drop::drop`]: ../std/ops/trait.Drop.html
[`std::ptr::drop_in_place`]: ../std/ptr/fn.drop_in_place.html
[array]: types.html#array-and-slice-types
[closure]: types.html#closure-types
[enum variant]: types.html#enumerated-types
[initialized]: glossary.html#initialized
[struct]: types.html#struct-types
[temporary]: expressions.html#temporary-lifetimes
[tuple]: types.html#tuple-types
[variable]: variables.html
8 changes: 4 additions & 4 deletions src/dynamically-sized-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ types">DSTs</abbr>. Such types can only be used in certain cases:
Notably: [variables], function parameters, [const] and [static] items must be
`Sized`.

[sized]: special-types-and-traits.html#sized
[Slices]: types.html#array-and-slice-types
[trait objects]: types.html#trait-objects
[Pointer types]: types.html#pointer-types
[variables]: variables.html
[Slices]: types.html#array-and-slice-types
[const]: items/constant-items.html
[sized]: special-types-and-traits.html#sized
[static]: items/static-items.html
[trait objects]: types.html#trait-objects
[variables]: variables.html
147 changes: 72 additions & 75 deletions src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ A *value expression* is an expression that represents an actual value.
The left operand of an [assignment][assign] or [compound assignment] expression
is a place expression context, as is the single operand of a unary [borrow], and
the operand of any [implicit borrow]. The discriminant or subject of a
[match expression][match] and right side of a [let statement] is also a place
[match expression][match] and right side of a [let statement][let] is also a place
expression context. All other expression contexts are value expression contexts.

> Note: Historically, place expressions were called *lvalues* and value
Expand All @@ -102,7 +102,7 @@ the remaining situations if that type is [`Sized`], then it may be possible to
move the value. Only the following place expressions may be moved out of:

* [Variables] which are not currently borrowed.
* [Temporary values](#temporary-lifetimes).
* [Temporary values].
* [Fields][field] of a place expression which can be moved out of and
doesn't implement [`Drop`].
* The result of [dereferencing] an expression with type [`Box<T>`] and that can
Expand Down Expand Up @@ -145,9 +145,9 @@ of a value expression to a `'static` slot occurs when the expression could be
written in a constant, borrowed, and dereferencing that borrow where the
expression was the originally written, without changing the runtime behavior.
That is, the promoted expression can be evaluated at compile-time and the
resulting value does not contain [interior mutability] or [destructors] (these
properties are determined based on the value where possible, e.g. `&None`
always has the type `&'static Option<_>`, as it contains nothing disallowed).
resulting value does not contain [interior mutability] or [destructors] \(these
properties are determined based on the value where possible, e.g. `&None` always
has the type `&'static Option<_>`, as it contains nothing disallowed).
Otherwise, the lifetime of temporary values is typically

- the innermost enclosing statement; the tail expression of a block is
Expand Down Expand Up @@ -233,9 +233,9 @@ Implicit borrows may be taken in the following expressions:

Certain types of expressions can be evaluated at compile time. These are called
_constant expressions_. Certain places, such as in
[constants](items/constant-items.html) and [statics](items/static-items.html),
[constants] and [statics][static variables],
require a constant expression, and are always evaluated at compile time. In
other places, such as in [`let` statements](statements.html#let-statements),
other places, such as in [`let` statements][let],
constant expressions may be evaluated at compile time. If errors, such as out
of bounds [array indexing] or [overflow] occurs,
then it is a compiler error if the value must be evaluated at compile time,
Expand All @@ -246,7 +246,7 @@ also constant expressions and do not cause any [`Drop::drop`][destructors] calls
to be ran.

* [Literals].
* [Paths] to [functions](items/functions.html) and constants.
* [Paths] to [functions] and constants.
Recursively defining constants is not allowed.
* [Tuple expressions].
* [Array expressions].
Expand All @@ -272,72 +272,69 @@ Many of the following operators and expressions can also be overloaded for
other types using traits in `std::ops` or `std::cmp`. These traits also
exist in `core::ops` and `core::cmp` with the same names.

[block expressions]: expressions/block-expr.html
[call expressions]: expressions/call-expr.html
[closure expressions]: expressions/closure-expr.html
[enum variant]: expressions/enum-variant-expr.html
[field]: expressions/field-expr.html
[grouped]: expressions/grouped-expr.html
[literals]: expressions/literal-expr.html
[match]: expressions/match-expr.html
[method-call]: expressions/method-call-expr.html
[paths]: expressions/path-expr.html
[range expressions]: expressions/range-expr.html
[struct]: expressions/struct-expr.html
[tuple expressions]: expressions/tuple-expr.html

[array expressions]: expressions/array-expr.html
[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions

[arithmetic, logical]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators
[assign]: expressions/operator-expr.html#assignment-expressions
[borrow]: expressions/operator-expr.html#borrow-operators
[cast]: expressions/operator-expr.html#type-cast-expressions
[comparison]: expressions/operator-expr.html#comparison-operators
[compound assignment]: expressions/operator-expr.html#compound-assignment-expressions
[dereferences]: expressions/operator-expr.html#the-dereference-operator
[dereferencing]: expressions/operator-expr.html#the-dereference-operator
[dereference operator]: expressions/operator-expr.html#the-dereference-operator
[lazy boolean]: expressions/operator-expr.html#lazy-boolean-operators
[negation]: expressions/operator-expr.html#negation-operators
[overflow]: expressions/operator-expr.html#overflow

[destructors]: destructors.html
[interior mutability]: interior-mutability.html
[`Box<T>`]: ../std/boxed/struct.Box.html
[`Copy`]: special-types-and-traits.html#copy
[`Drop`]: special-types-and-traits.html#drop
[`Sized`]: special-types-and-traits.html#sized
[implicit borrow]: #implicit-borrows
[implicitly mutably borrowed]: #implicit-borrows
[let]: statements.html#let-statements
[let statement]: statements.html#let-statements
[Mutable `static` items]: items/static-items.html#mutable-statics
[slice]: types.html#array-and-slice-types
[static variables]: items/static-items.html
[Temporary values]: #temporary-lifetimes
[Variables]: variables.html

[_ArrayExpression_]: expressions/array-expr.html
[_BlockExpression_]: expressions/block-expr.html
[_BreakExpression_]: expressions/loop-expr.html#break-expressions
[_CallExpression_]: expressions/call-expr.html
[_ClosureExpression_]: expressions/closure-expr.html
[_ContinueExpression_]: expressions/loop-expr.html#continue-expressions
[Temporary values]: #temporary-lifetimes
[Variables]: variables.html
[_ArrayExpression_]: expressions/array-expr.html
[_BlockExpression_]: expressions/block-expr.html
[_BreakExpression_]: expressions/loop-expr.html#break-expressions
[_CallExpression_]: expressions/call-expr.html
[_ClosureExpression_]: expressions/closure-expr.html
[_ContinueExpression_]: expressions/loop-expr.html#continue-expressions
[_EnumerationVariantExpression_]: expressions/enum-variant-expr.html
[_FieldExpression_]: expressions/field-expr.html
[_GroupedExpression_]: expressions/grouped-expr.html
[_IfExpression_]: expressions/if-expr.html#if-expressions
[_IfLetExpression_]: expressions/if-expr.html#if-let-expressions
[_IndexExpression_]: expressions/array-expr.html#array-and-slice-indexing-expressions
[_LiteralExpression_]: expressions/literal-expr.html
[_LoopExpression_]: expressions/loop-expr.html
[_MatchExpression_]: expressions/match-expr.html
[_MethodCallExpression_]: expressions/method-call-expr.html
[_OperatorExpression_]: expressions/operator-expr.html
[_PathExpression_]: expressions/path-expr.html
[_RangeExpression_]: expressions/range-expr.html
[_ReturnExpression_]: expressions/return-expr.html
[_StructExpression_]: expressions/struct-expr.html
[_TupleExpression_]: expressions/tuple-expr.html
[_TupleIndexingExpression_]: expressions/tuple-expr.html#tuple-indexing-expressions
[_FieldExpression_]: expressions/field-expr.html
[_GroupedExpression_]: expressions/grouped-expr.html
[_IfExpression_]: expressions/if-expr.html#if-expressions
[_IfLetExpression_]: expressions/if-expr.html#if-let-expressions
[_IndexExpression_]: expressions/array-expr.html#array-and-slice-indexing-expressions
[_LiteralExpression_]: expressions/literal-expr.html
[_LoopExpression_]: expressions/loop-expr.html
[_MatchExpression_]: expressions/match-expr.html
[_MethodCallExpression_]: expressions/method-call-expr.html
[_OperatorExpression_]: expressions/operator-expr.html
[_PathExpression_]: expressions/path-expr.html
[_RangeExpression_]: expressions/range-expr.html
[_ReturnExpression_]: expressions/return-expr.html
[_StructExpression_]: expressions/struct-expr.html
[_TupleExpression_]: expressions/tuple-expr.html
[_TupleIndexingExpression_]: expressions/tuple-expr.html#tuple-indexing-expressions
[`Box<T>`]: ../std/boxed/struct.Box.html
[`Copy`]: special-types-and-traits.html#copy
[`Drop`]: special-types-and-traits.html#drop
[`Sized`]: special-types-and-traits.html#sized
[arithmetic, logical]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators
[array expressions]: expressions/array-expr.html
[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions
[assign]: expressions/operator-expr.html#assignment-expressions
[block expressions]: expressions/block-expr.html
[borrow]: expressions/operator-expr.html#borrow-operators
[call expressions]: expressions/call-expr.html
[cast]: expressions/operator-expr.html#type-cast-expressions
[closure expressions]: expressions/closure-expr.html
[comparison]: expressions/operator-expr.html#comparison-operators
[compound assignment]: expressions/operator-expr.html#compound-assignment-expressions
[constants]: items/constant-items.html
[dereference operator]: expressions/operator-expr.html#the-dereference-operator
[dereferences]: expressions/operator-expr.html#the-dereference-operator
[dereferencing]: expressions/operator-expr.html#the-dereference-operator
[destructors]: destructors.html
[enum variant]: expressions/enum-variant-expr.html
[field]: expressions/field-expr.html
[functions]: items/functions.html
[grouped]: expressions/grouped-expr.html
[implicit borrow]: #implicit-borrows
[implicitly mutably borrowed]: #implicit-borrows
[interior mutability]: interior-mutability.html
[lazy boolean]: expressions/operator-expr.html#lazy-boolean-operators
[let]: statements.html#let-statements
[literals]: expressions/literal-expr.html
[match]: expressions/match-expr.html
[method-call]: expressions/method-call-expr.html
[negation]: expressions/operator-expr.html#negation-operators
[overflow]: expressions/operator-expr.html#overflow
[paths]: expressions/path-expr.html
[range expressions]: expressions/range-expr.html
[slice]: types.html#array-and-slice-types
[static variables]: items/static-items.html
[struct]: expressions/struct-expr.html
[tuple expressions]: expressions/tuple-expr.html
Loading