Skip to content

FN collection_is_never_read: grabbing unit value of push() #10488

Closed
@matthiaskrgr

Description

@matthiaskrgr

Summary

,

Lint Name

collection_is_never_read

Reproducer

I tried this code:

#![warn(clippy::collection_is_never_read)]

pub fn main() {
    let mut x: Vec<_> = vec![1, 2, 3];
    x.push(4);
    // the println() is read as a use, but the .push() returns () so we still never actually use the resulting vec
    println!("{:?}", x.push(5));
}

I expected to see this happen:
Lint trigggers

Instead, this happened:
Linnt doesn't trigger

Version

rustc 1.70.0-nightly (8a73f50d8 2023-03-11)
binary: rustc
commit-hash: 8a73f50d875840b8077b8ec080fa41881d7ce40d
commit-date: 2023-03-11
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions