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

Problematic let_and_return (false positive?) #848

Closed
llogiq opened this issue Apr 10, 2016 · 2 comments · Fixed by #850
Closed

Problematic let_and_return (false positive?) #848

llogiq opened this issue Apr 10, 2016 · 2 comments · Fixed by #850
Labels
C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on

Comments

@llogiq
Copy link
Contributor

llogiq commented Apr 10, 2016

From carboxyl:

                        let ret = strong.read().unwrap().call();
                        ret

However, when I change to strong.read().unwrap().call(), I get

src/signal.rs:412:25: 412:31 error: `strong` does not live long enough
src/signal.rs:412                         strong.read().unwrap().call()
                                          ^~~~~~
src/signal.rs:410:29: 413:22 note: reference must be valid for the destruction scope surrounding block at 410:28...
src/signal.rs:410                     move || {
src/signal.rs:411                         let strong = sig.upgrade().unwrap();
src/signal.rs:412                         strong.read().unwrap().call()
src/signal.rs:413                     }
src/signal.rs:411:61: 413:22 note: ...but borrowed value is only valid for the block suffix following statement 0 at 411:60
src/signal.rs:411                         let strong = sig.upgrade().unwrap();
src/signal.rs:412                         strong.read().unwrap().call()
src/signal.rs:413                     }

At the very least, the docs should reflect this possible problem. I note that this is within a move || { .. } closure. Perhaps this has something to do with the error.

@llogiq llogiq added C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on labels Apr 10, 2016
@oli-obk
Copy link
Contributor

oli-obk commented Apr 11, 2016

This is a rust-issue: rust-lang/rust#31439

@llogiq
Copy link
Contributor Author

llogiq commented Apr 11, 2016

We should still document this as a possible problem as long as the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing E-hard Call for participation: This a hard problem and requires more experience or effort to work on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants