-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
S-triageStatus: PR was triaged and is waiting for an action from a maintainer (closing/moving/... the PR)Status: PR was triaged and is waiting for an action from a maintainer (closing/moving/... the PR)
Description
The following code
#![feature(unsized_locals)]
fn a(f: Box<dyn FnOnce()>) {
f()
}
fn main() {
let f = || println!("Hello!");
a(Box::new(f))
}
is now allowed in nightly. However, Clippy gives inaccurate lint:
Checking playground v0.0.1 (/playground)
warning: this argument is passed by value, but not consumed in the function body
--> src/main.rs:2:9
|
2 | fn a(f: Box<dyn FnOnce()>) {
| ^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Box<dyn FnOnce()>`
|
= note: #[warn(clippy::needless_pass_by_value)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value
Finished dev [unoptimized + debuginfo] target(s) in 0.66s
Because when run the code above, it do consumes the variable f
when using unsized rvalues, and it cannot run without it.
Metadata
Metadata
Assignees
Labels
S-triageStatus: PR was triaged and is waiting for an action from a maintainer (closing/moving/... the PR)Status: PR was triaged and is waiting for an action from a maintainer (closing/moving/... the PR)