Skip to content

Enhance mem_replace_with_default with other constructors #6562

Closed
@camsteffen

Description

@camsteffen

mem_replace_with_default could recognize std library constructors that are equivalent to Default::default() such as Vec::new(), HashMap::new(), etc. This may also apply to #3812 when it is implemented, and the two lints may share a list of known "default-equivalent" constructors. vec![] should also be recognized.

Example: std::mem::replace(&mut v, Vec::new())

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesI-false-negativeIssue: The lint should have been triggered on code, but wasn'tgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions