Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emit needless_return on return stmts using borrow #9008

Closed
wants to merge 1 commit into from

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
4 participants