Skip to content

Commit

Permalink
Emit both E0385 and E0505. Work with 2015/2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgalex committed Feb 20, 2019
1 parent d960310 commit a371022
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/scope/borrow.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@ fn main() {
borrow_i32(&boxed_i32);
borrow_i32(&stacked_i32);
// Take a reference to the data contained inside the box
let _ref_to_i32: &i32 = &boxed_i32;
{
// Take a reference to the data contained inside the box
let _ref_to_i32: &i32 = &boxed_i32;
// Can't destroy `boxed_i32` while the inner value is borrowed later in scope.
eat_box_i32(boxed_i32);
// FIXME ^ Comment out this line
// Error!
// Can't destroy `boxed_i32` while the inner value is borrowed later in scope.
eat_box_i32(boxed_i32);
// FIXME ^ Comment out this line
// Attempt to borrow `_ref_to_i32` after inner value is destroyed
borrow_i32(_ref_to_i32);
// `_ref_to_i32` goes out of scope and is no longer borrowed.
}
// Attempt to borrow `_ref_to_i32` after inner value is destroyed
borrow_i32(_ref_to_i32);
// `boxed_i32` can now give up ownership to `eat_box` and be destroyed
eat_box_i32(boxed_i32);
}
```

0 comments on commit a371022

Please sign in to comment.