Skip to content

Conversation

dswij
Copy link
Member

@dswij dswij commented Jun 16, 2022

Fix #8978

This check is added on #5903 to fix #5858. Though, the test added here compiles as of today, so this can be removed. (playground)

changelog: [needless_return] now emits on on return stmts using borrow

@rust-highfive
Copy link

r? @giraffate

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 16, 2022
@Alexendoo
Copy link
Member

I think that's due to rust-lang/rust#93965

use std::cell::RefCell;

fn foo(x: RefCell<String>) -> String {
    let y = x;
    return y.borrow().clone();
}

wouldn't compile if the return were removed (from https://github.com/rust-lang/rust/blob/9a74608543d499bcc7dd505e195e8bfab9447315/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.rs)

@dswij
Copy link
Member Author

dswij commented Jun 17, 2022

Oh wait, you're right. 😅
Closing this one

@dswij dswij closed this Jun 17, 2022
bors added a commit that referenced this pull request Jun 20, 2022
Use `RefCell` in `needless_return` tests

changelog: none

The stdio locks no longer fail to compile if the `return` is removed due to them now being `'static` (#9008)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

needless_return has false negative pattern needless_return false positive when a temporary borrows a local variable
4 participants