-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
False positive for redundant_closure lint #1439
Comments
Ugh... |
This is also triggering on my code which does not have a box, but is similarly lazy. Here is a minimal repro for v0.0.191. struct Wrapper<T>(Option<T>);
impl<T> Wrapper<T> {
fn map_it<U, V>(&mut self, other: Wrapper<U>) -> Wrapper<V>
where
T: FnOnce(U) -> V,
{
Wrapper(other.0.map(|u| self.0.take().expect("")(u)))
}
}
EDIT: Too minimal, i think clippy is correct here. |
Going to take a look at this over the next couple of days |
Here is a pretty minimal repro: #[allow(unknown_lints, blacklisted_name)]
fn main() {
let mut foo = Some(|x| x * x);
let bar = [Ok(1), Err(2)];
let baz: Vec<_> = bar.iter().map(|x| x.map_err(|e| foo.take().unwrap()(e))).collect();
// let baz: Vec<_> = bar.iter().map(|x| x.map_err(foo.take().unwrap())).collect();
println!("{:?}", baz);
} |
Documenting rust-lang#1439 until it gets fixed.
I didn't have enough time to dig into this, unfortunately. If someone wants to pick this up, feel free! |
These two cases were fixed by rust-lang#4008. Closes rust-lang#1439 changelog: none
These two cases were fixed by rust-lang#4008. Closes rust-lang#1439 changelog: none
I wrote a simple thunk implementation:
However, clippy complains that the closure in
Thunk::new
is redundant:But if I use clippy's suggestion, I get this error:
This seems like a bug in the
redundant_closure
lint.The text was updated successfully, but these errors were encountered: