diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-12 14:49:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-12 14:49:03 +0200 |
| commit | b3372ba1d01b0d9e26a231a8c0aa062c6f75d9f4 (patch) | |
| tree | 6456b244735c8caf7798edbc5a66f079ae5bb519 /src | |
| parent | b83c2e952c493eaf5e006899fbe80acbcba06988 (diff) | |
| parent | e2e41c9527e64120b5dedfd1f0fdb29d03112d6d (diff) | |
| download | rust-b3372ba1d01b0d9e26a231a8c0aa062c6f75d9f4.tar.gz rust-b3372ba1d01b0d9e26a231a8c0aa062c6f75d9f4.zip | |
Rollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC
Clean up E0515 explanation r? @Dylan-DPC
Diffstat (limited to 'src')
| -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: ``` |
