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

new lint: passing 0 as length to Vec::resize #5444

Closed
KamilaBorowska opened this issue Apr 10, 2020 · 7 comments
Closed

new lint: passing 0 as length to Vec::resize #5444

KamilaBorowska opened this issue Apr 10, 2020 · 7 comments
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Apr 10, 2020

Clippy should inform about passing 0 as length to resize. It's not useful, and it's likely a mistake caused by swapping the parameter order.

Example code:

fn main() {
    let mut v = Vec::new();
    v.resize(0, 1024);
}
@flip1995 flip1995 added L-correctness Lint: Belongs in the correctness lint group good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints L-suggestion Lint: Improving, adding or fixing lint suggestions labels Apr 15, 2020
@JarredAllen
Copy link
Contributor

I can implement this.

@mlegner
Copy link
Contributor

mlegner commented May 1, 2020

Are you still working on this, @JarredAllen? Otherwise, I could have a go at it.

@JarredAllen
Copy link
Contributor

I had said I would do this thinking that the other issue I was working on would wrap up quickly, but then it turned out that there was more to do (and I now also have to deal with finals). If you want to handle this, feel free to do so.

@tnielens
Copy link
Contributor

@mlegner are you still active on this one?

@mlegner
Copy link
Contributor

mlegner commented May 21, 2020

@montrivo I'm sorry, I completely forgot about this issue. 😞
No, I'm currently not working on it and won't have time in the next few days. So, if you're interested, go ahead.

@tnielens
Copy link
Contributor

Thanks for the quick answer. I'll take a look at it.

flip1995 added a commit to flip1995/rust-clippy that referenced this issue May 31, 2020
… r=yaahc,flip1995

new lint: vec_resize_to_zero

implements rust-lang#5444

changelog: new lint vec_resize_to_zero
bors added a commit that referenced this issue May 31, 2020
…ip1995

new lint: vec_resize_to_zero

implements #5444

changelog: new lint vec_resize_to_zero
@defunctio
Copy link

this should have been closed by #5637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

6 participants