diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-04-11 18:58:03 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-04-11 18:58:03 +0200 |
| commit | e2e41c9527e64120b5dedfd1f0fdb29d03112d6d (patch) | |
| tree | e012503b15347c115af2b7f2002ca1a9d1000f6a /src/librustc_error_codes/error_codes | |
| parent | 167510f776891f2b0b18d1168ed42377a63493a7 (diff) | |
| download | rust-e2e41c9527e64120b5dedfd1f0fdb29d03112d6d.tar.gz rust-e2e41c9527e64120b5dedfd1f0fdb29d03112d6d.zip | |
Clean up E0515 explanation
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0515.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_error_codes/error_codes/E0515.md b/src/librustc_error_codes/error_codes/E0515.md index 9580b6f92ac..0f4fbf67223 100644 --- a/src/librustc_error_codes/error_codes/E0515.md +++ b/src/librustc_error_codes/error_codes/E0515.md @@ -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: @@ -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: ``` |
