Closed
Description
The following code works but returns a clippy lint error: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=2417f60b483ac63fd3ffd90b66d6db16
warning: returning the result of a let binding from a block. Consider returning the expression directly.
--> src/main.rs:7:5
|
7 | ret
| ^^^
|
= note: #[warn(clippy::let_and_return)] on by default
note: this expression can be directly returned
--> src/main.rs:6:15
|
6 | let ret = foo.borrow().baz();
| ^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#let_and_return
When using the suggestion of clippy to remove the let, it fails to compile: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=285ab39429037278c362bbb6d7ffddf6
error[E0597]: `foo` does not live long enough
--> src/main.rs:6:5
|
6 | foo.borrow().baz()
| ^^^ borrowed value does not live long enough
7 | }
| - `foo` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.