Skip to content

Commit b3372ba

Browse files
authored
Rollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC
Clean up E0515 explanation r? @Dylan-DPC
2 parents b83c2e9 + e2e41c9 commit b3372ba

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

+4-4
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)