Skip to content

Commit 7242f23

Browse files
authored
Rollup merge of rust-lang#71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC
Clean up E0515 explanation r? @Dylan-DPC
2 parents 73a962d + e2e41c9 commit 7242f23

File tree

1 file changed

+4
-4
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+4
-4
lines changed

src/librustc_error_codes/error_codes/E0515.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
Cannot return value that references local variable
2-
3-
Local variables, function parameters and temporaries are all dropped before the
4-
end of the function body. So a reference to them cannot be returned.
1+
A reference to a local variable was returned.
52

63
Erroneous code example:
74

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

20+
Local variables, function parameters and temporaries are all dropped before the
21+
end of the function body. So a reference to them cannot be returned.
22+
2323
Consider returning an owned value instead:
2424

2525
```

0 commit comments

Comments
 (0)