Skip to content

Unnecessary Vec/VecDeque reserve lint #8982

Description

@leonardo-m

What it does

Inspired by:
rust-lang/rust#97922

In a basic case like this Clippy could suggest to remove the call to reserve() because it's unnecessary:

Lint Name

unnecessary_reserve

Category

pedantic

Advantage

No response

Drawbacks

No response

Example

fn test1(v: &mut Vec<u32>, b: &[u32]) {
    v.reserve(b.len());
    v.extend(b);
}

The same for VecDeque.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions