Skip to content

Commit 0ec5eba

Browse files
authored
Merge pull request #1979 from dianne/lifetime-extension-doctests
clean up and properly test temporary lifetime extension in doctests
2 parents b091a8a + 6c5013c commit 0ec5eba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/destructors.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,18 @@ Here are some examples where expressions have extended temporary scopes:
448448

449449
```rust
450450
# fn temp() {}
451-
# trait Use { fn use_temp(&self) -> &Self { self } }
452-
# impl Use for () {}
453451
// The temporary that stores the result of `temp()` lives in the same scope
454452
// as x in these cases.
455453
let x = &temp();
454+
# x;
456455
let x = &temp() as &dyn Send;
456+
# x;
457457
let x = (&*&temp(),);
458+
# x;
458459
let x = { [Some(&temp()) ] };
460+
# x;
459461
let ref x = temp();
462+
# x;
460463
let ref x = *&temp();
461464
# x;
462465
```
@@ -471,6 +474,7 @@ Here are some examples where expressions don't have extended temporary scopes:
471474
// end of the let statement in these cases.
472475
473476
let x = std::convert::identity(&temp()); // ERROR
477+
# x;
474478
let x = (&temp()).use_temp(); // ERROR
475479
# x;
476480
```

0 commit comments

Comments
 (0)