Skip to content

Commit

Permalink
Clean up E0515 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 11, 2020
1 parent 167510f commit e2e41c9
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 e2e41c9

Please sign in to comment.