From e2e41c9527e64120b5dedfd1f0fdb29d03112d6d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 11 Apr 2020 18:58:03 +0200 Subject: [PATCH] Clean up E0515 explanation --- src/librustc_error_codes/error_codes/E0515.md | 8 ++++---- 1 file 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: ```