-
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
vec_init_then_push incorrectly fires when the push()
is in a loop
body
#7019
Comments
This should be fixed by #6697. Can you provide a minimal reproducible example? |
I spent about 15 minutes trying to get a repro going but couldn't trigger the false positive. I'll try again later or see what I can gather about the context. |
I came across this, and managed to simplify syntax down to this. I can reproduce locally #[allow(clippy::while_let_loop)]
#[allow(clippy::never_loop)]
#[allow(clippy::match_single_binding)]
fn foo() {
let mut v = vec![];
loop {
match () {
() => {
v.push(());
return;
}
}
}
} |
That version predates #6697. Your example no longer lints. |
That's why I mentioned play.rust-lang.org as well, as I assume that version included that fix. Is there something that prevents that example from being a MCVE? |
We need an example that is a false positive in the latest version, or else there is no issue here. |
But the issue was opened for clippy 0.1.51 (2fd73fab 2021-03-23), the same version I was using.
Yes, my example leads me to believe this issue has been resolved. |
Lint name: vec_init_then_push
I tried this code:
I expected to see this happen: The lint to not fire, since this is a valid use case for init then push.
Instead, this happened: The lint fired.
Meta
cargo clippy -V
: clippy 0.1.51 (2fd73fab 2021-03-23)rustc -Vv
:The text was updated successfully, but these errors were encountered: