Fix [needless_return] false negative when returned expression borrows a value
Fixes #12907 changelog: Fix [`needless_return`] false negative when returned expression borrows a value
This commit is contained in:
parent
377d72ae8b
commit
af35dcd330
4 changed files with 39 additions and 5 deletions
|
|
@ -355,4 +355,8 @@ fn conjunctive_blocks() -> String {
|
|||
({ "a".to_string() } + "b" + { "c" })
|
||||
}
|
||||
|
||||
fn issue12907() -> String {
|
||||
"".split("").next().unwrap().to_string()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -365,4 +365,8 @@ fn conjunctive_blocks() -> String {
|
|||
return { "a".to_string() } + "b" + { "c" };
|
||||
}
|
||||
|
||||
fn issue12907() -> String {
|
||||
return "".split("").next().unwrap().to_string();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -665,5 +665,17 @@ LL - return { "a".to_string() } + "b" + { "c" };
|
|||
LL + ({ "a".to_string() } + "b" + { "c" })
|
||||
|
|
||||
|
||||
error: aborting due to 53 previous errors
|
||||
error: unneeded `return` statement
|
||||
--> tests/ui/needless_return.rs:369:5
|
||||
|
|
||||
LL | return "".split("").next().unwrap().to_string();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove `return`
|
||||
|
|
||||
LL - return "".split("").next().unwrap().to_string();
|
||||
LL + "".split("").next().unwrap().to_string()
|
||||
|
|
||||
|
||||
error: aborting due to 54 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue