Skip to content

Commit e2e41c9

Browse files
Clean up E0515 explanation
1 parent 167510f commit e2e41c9

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)