Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/rustc_error_codes/src/error_codes/E0515.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ 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.
Local variables, function parameters and temporaries are all dropped before
the end of the function body. A returned reference (or struct containing a
reference) to such a dropped value would immediately be invalid. Therefore
it is not allowed to return such a reference.

Consider returning an owned value instead:
Consider returning a value that takes ownership of local data instead of
referencing it:

```
use std::vec::IntoIter;
Expand Down
Loading