Skip to content

Commit

Permalink
Rollup merge of rust-lang#71034 - GuillaumeGomez:cleanup-e0515, r=Dyl…
Browse files Browse the repository at this point in the history
…an-DPC

Clean up E0515 explanation

r? @Dylan-DPC
  • Loading branch information
Dylan-DPC authored Apr 12, 2020
2 parents 73a962d + e2e41c9 commit 7242f23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librustc_error_codes/error_codes/E0515.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
Cannot return value that references local variable

Local variables, function parameters and temporaries are all dropped before the
end of the function body. So a reference to them cannot be returned.
A reference to a local variable was returned.

Erroneous code example:

Expand All @@ -20,6 +17,9 @@ fn get_dangling_iterator<'a>() -> Iter<'a, i32> {
}
```

Local variables, function parameters and temporaries are all dropped before the
end of the function body. So a reference to them cannot be returned.

Consider returning an owned value instead:

```
Expand Down

0 comments on commit 7242f23

Please sign in to comment.