Rollup merge of #23385 - tamird:cleanup-whitespace, r=alexcrichton
r? @alexcrichton Conflicts: src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
This commit is contained in:
commit
fad4c380e8
419 changed files with 154 additions and 561 deletions
|
|
@ -290,7 +290,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
|
|||
|
||||
# Items and attributes
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
## Items
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ item : mod_item | fn_item | type_item | struct_item | enum_item
|
|||
|
||||
### Type Parameters
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Modules
|
||||
|
||||
|
|
@ -338,35 +338,35 @@ path_item : ident | "mod" ;
|
|||
|
||||
### Functions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Generic functions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Unsafety
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
##### Unsafe functions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
##### Unsafe blocks
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Diverging functions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Type definitions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Structures
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Constant items
|
||||
|
||||
|
|
@ -382,15 +382,15 @@ static_item : "static" ident ':' type '=' expr ';' ;
|
|||
|
||||
#### Mutable statics
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Traits
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Implementations
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### External blocks
|
||||
|
||||
|
|
@ -401,11 +401,11 @@ extern_block : [ foreign_fn ] * ;
|
|||
|
||||
## Visibility and Privacy
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Re-exporting and Visibility
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
## Attributes
|
||||
|
||||
|
|
@ -420,11 +420,11 @@ meta_seq : meta_item [ ',' meta_seq ] ? ;
|
|||
|
||||
## Statements
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Declaration statements
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
A _declaration statement_ is one that introduces one or more *names* into the
|
||||
enclosing statement block. The declared names may denote new slots or new
|
||||
|
|
@ -432,7 +432,7 @@ items.
|
|||
|
||||
#### Item declarations
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
An _item declaration statement_ has a syntactic form identical to an
|
||||
[item](#items) declaration within a module. Declaring an item — a
|
||||
|
|
@ -450,35 +450,35 @@ init : [ '=' ] expr ;
|
|||
|
||||
### Expression statements
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
## Expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Lvalues, rvalues and temporaries
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Moved and copied types
|
||||
|
||||
**FIXME:** Do we want to capture this in the grammar as different productions?
|
||||
**FIXME:** Do we want to capture this in the grammar as different productions?
|
||||
|
||||
### Literal expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Path expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Tuple expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Unit expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Structure expressions
|
||||
|
||||
|
|
@ -527,7 +527,7 @@ idx_expr : expr '[' expr ']' ;
|
|||
|
||||
### Unary operator expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Binary operator expressions
|
||||
|
||||
|
|
@ -537,31 +537,31 @@ binop_expr : expr binop expr ;
|
|||
|
||||
#### Arithmetic operators
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Bitwise operators
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Lazy boolean operators
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Comparison operators
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Type cast expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Assignment expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Compound assignment expressions
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Operator precedence
|
||||
|
||||
|
|
@ -680,49 +680,49 @@ return_expr : "return" expr ? ;
|
|||
|
||||
# Type system
|
||||
|
||||
**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
|
||||
**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
|
||||
|
||||
## Types
|
||||
|
||||
### Primitive types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Machine types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
#### Machine-dependent integer types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Textual types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Tuple types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Array, and Slice types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Structure types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Enumerated types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Pointer types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Function types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Closure types
|
||||
|
||||
|
|
@ -739,15 +739,15 @@ bound := path | lifetime
|
|||
|
||||
### Object types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Type parameters
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
### Self types
|
||||
|
||||
**FIXME:** grammar?
|
||||
**FIXME:** grammar?
|
||||
|
||||
## Type kinds
|
||||
|
||||
|
|
@ -755,7 +755,7 @@ bound := path | lifetime
|
|||
|
||||
# Memory and concurrency models
|
||||
|
||||
**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
|
||||
**FIXME:** is this entire chapter relevant here? Or should it all have been covered by some production already?
|
||||
|
||||
## Memory model
|
||||
|
||||
|
|
|
|||
|
|
@ -63,4 +63,3 @@ function populate_rust_search() {
|
|||
populate_site_search();
|
||||
populate_rust_search();
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ languages.
|
|||
|
||||
A *vector* is a dynamic or "growable" array, implemented as the standard
|
||||
library type [`Vec<T>`](../std/vec/) (we'll talk about what the `<T>` means
|
||||
later). Vectors always allocate their data on the heap. Vectors are to slices
|
||||
later). Vectors always allocate their data on the heap. Vectors are to slices
|
||||
what `String` is to `&str`. You can create them with the `vec!` macro:
|
||||
|
||||
```{rust}
|
||||
|
|
|
|||
|
|
@ -551,9 +551,9 @@ module, we now have a `phrases::japanese::hello()` function and a
|
|||
`phrases::japanese::farewells::goodbye()`. Our internal organization doesn't
|
||||
define our external interface.
|
||||
|
||||
Here we have a `pub use` for each function we want to bring into the
|
||||
Here we have a `pub use` for each function we want to bring into the
|
||||
`japanese` scope. We could alternatively use the wildcard syntax to include
|
||||
everything from `greetings` into the current scope: `pub use self::greetings::*`.
|
||||
everything from `greetings` into the current scope: `pub use self::greetings::*`.
|
||||
|
||||
What about the `self`? Well, by default, `use` declarations are absolute paths,
|
||||
starting from your crate root. `self` makes that path relative to your current
|
||||
|
|
|
|||
|
|
@ -306,23 +306,23 @@ println!("{}", x + y);
|
|||
Here's the same explanation, in raw text:
|
||||
|
||||
> First, we set `x` to five:
|
||||
>
|
||||
>
|
||||
> ```text
|
||||
> let x = 5;
|
||||
> # let y = 6;
|
||||
> # println!("{}", x + y);
|
||||
> ```
|
||||
>
|
||||
>
|
||||
> Next, we set `y` to six:
|
||||
>
|
||||
>
|
||||
> ```text
|
||||
> # let x = 5;
|
||||
> let y = 6;
|
||||
> # println!("{}", x + y);
|
||||
> ```
|
||||
>
|
||||
>
|
||||
> Finally, we print the sum of `x` and `y`:
|
||||
>
|
||||
>
|
||||
> ```text
|
||||
> # let x = 5;
|
||||
> # let y = 6;
|
||||
|
|
@ -521,4 +521,3 @@ This sets a few different options, with a logo, favicon, and a root URL.
|
|||
- `--html-before-content FILE`: includes the contents of FILE directly after
|
||||
`<body>`, before the rendered content (including the search bar).
|
||||
- `--html-after-content FILE`: includes the contents of FILE after all the rendered content.
|
||||
|
||||
|
|
|
|||
|
|
@ -543,4 +543,3 @@ The `extern` makes this function adhere to the C calling convention, as
|
|||
discussed above in "[Foreign Calling
|
||||
Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle`
|
||||
attribute turns off Rust's name mangling, so that it is easier to link to.
|
||||
|
||||
|
|
|
|||
|
|
@ -61,15 +61,15 @@ struct Circle {
|
|||
|
||||
impl Circle {
|
||||
fn reference(&self) {
|
||||
println!("taking self by reference!");
|
||||
println!("taking self by reference!");
|
||||
}
|
||||
|
||||
fn mutable_reference(&mut self) {
|
||||
println!("taking self by mutable reference!");
|
||||
println!("taking self by mutable reference!");
|
||||
}
|
||||
|
||||
fn takes_ownership(self) {
|
||||
println!("taking ownership of self!");
|
||||
println!("taking ownership of self!");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ However, the common case is that it is more efficient to use static dispatch,
|
|||
and one can always have a thin statically-dispatched wrapper function that does
|
||||
a dynamic dispatch, but not vice versa, meaning static calls are more flexible.
|
||||
The standard library tries to be statically dispatched where possible for this
|
||||
reason.
|
||||
reason.
|
||||
|
||||
## Dynamic dispatch
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
% Testing
|
||||
|
||||
> Program testing can be a very effective way to show the presence of bugs, but
|
||||
> it is hopelessly inadequate for showing their absence.
|
||||
> it is hopelessly inadequate for showing their absence.
|
||||
>
|
||||
> Edsger W. Dijkstra, "The Humble Programmer" (1972)
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ extern crate adder;
|
|||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(4, adder::add_two(2));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This looks similar to our previous tests, but slightly different. We now have
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue