Skip to content

Commit 35cd622

Browse files
authored
Merge pull request #280 from JohnTitor/edition-2018
Upgrade to edition 2018
2 parents f30bc44 + 35f4209 commit 35cd622

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

book.toml

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ description = "The Dark Arts of Advanced and Unsafe Rust Programming"
55

66
[output.html]
77
git-repository-url = "https://github.com/rust-lang/nomicon"
8+
9+
[rust]
10+
edition = "2018"

src/lifetime-mismatch.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Given the following code:
44

5-
```rust,edition2018,compile_fail
5+
```rust,compile_fail
66
#[derive(Debug)]
77
struct Foo;
88
@@ -76,7 +76,7 @@ The following code fails to compile, because Rust doesn't understand that the bo
7676
is no longer needed and conservatively falls back to using a whole scope for it.
7777
This will eventually get fixed.
7878

79-
```rust,edition2018,compile_fail
79+
```rust,compile_fail
8080
# use std::collections::HashMap;
8181
# use std::hash::Hash;
8282
fn get_default<'m, K, V>(map: &'m mut HashMap<K, V>, key: K) -> &'m mut V

src/lifetimes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ The following snippet compiles, because after printing `x`, it is no longer
226226
needed, so it doesn't matter if it is dangling or aliased (even though the
227227
variable `x` *technically* exists to the very end of the scope).
228228

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

241-
```rust,edition2018,compile_fail
241+
```rust,compile_fail
242242
#[derive(Debug)]
243243
struct X<'a>(&'a i32);
244244
@@ -258,7 +258,7 @@ One way to convince the compiler that `x` is no longer valid is by using `drop(x
258258
Furthermore, there might be multiple possible last uses of the borrow, for
259259
example in each branch of a condition.
260260

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

281-
```rust,edition2018
281+
```rust
282282
let mut data = vec![1, 2, 3];
283283
// This mut allows us to change where the reference points to
284284
let mut x = &data[0];

0 commit comments

Comments
 (0)