Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to edition 2018 #280

Merged
merged 1 commit into from
Jun 18, 2021
Merged
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
3 changes: 3 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ description = "The Dark Arts of Advanced and Unsafe Rust Programming"

[output.html]
git-repository-url = "https://github.com/rust-lang/nomicon"

[rust]
edition = "2018"
4 changes: 2 additions & 2 deletions src/lifetime-mismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Given the following code:

```rust,edition2018,compile_fail
```rust,compile_fail
#[derive(Debug)]
struct Foo;

Expand Down Expand Up @@ -76,7 +76,7 @@ The following code fails to compile, because Rust doesn't understand that the bo
is no longer needed and conservatively falls back to using a whole scope for it.
This will eventually get fixed.

```rust,edition2018,compile_fail
```rust,compile_fail
# use std::collections::HashMap;
# use std::hash::Hash;
fn get_default<'m, K, V>(map: &'m mut HashMap<K, V>, key: K) -> &'m mut V
Expand Down
8 changes: 4 additions & 4 deletions src/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ The following snippet compiles, because after printing `x`, it is no longer
needed, so it doesn't matter if it is dangling or aliased (even though the
variable `x` *technically* exists to the very end of the scope).

```rust,edition2018
```rust
let mut data = vec![1, 2, 3];
let x = &data[0];
println!("{}", x);
Expand All @@ -238,7 +238,7 @@ However, if the value has a destructor, the destructor is run at the end of the
scope. And running the destructor is considered a use ‒ obviously the last one.
So, this will *not* compile.

```rust,edition2018,compile_fail
```rust,compile_fail
#[derive(Debug)]
struct X<'a>(&'a i32);

Expand All @@ -258,7 +258,7 @@ One way to convince the compiler that `x` is no longer valid is by using `drop(x
Furthermore, there might be multiple possible last uses of the borrow, for
example in each branch of a condition.

```rust,edition2018
```rust
# fn some_condition() -> bool { true }
let mut data = vec![1, 2, 3];
let x = &data[0];
Expand All @@ -278,7 +278,7 @@ borrows just being tied to the same local variable. This often happens around
loops (writing a new value of a variable at the end of the loop and using it for
the last time at the top of the next iteration).

```rust,edition2018
```rust
let mut data = vec![1, 2, 3];
// This mut allows us to change where the reference points to
let mut x = &data[0];
Expand Down