Skip to content

corner cases for default_trait_access #10936

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

Open
pacak opened this issue Jun 12, 2023 · 2 comments
Open

corner cases for default_trait_access #10936

pacak opened this issue Jun 12, 2023 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@pacak
Copy link
Contributor

pacak commented Jun 12, 2023

Description

Currently for code like

let foo = Default::default();

or

foo: Default::default(),

where foo is a variable of type Option<usize>
suggests to replace it with Option::default(), which is not wrong but suggesting None would be better. Can probably be extended to some other types in stdlib.

Version

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Additional Labels

No response

@Centri3
Copy link
Member

Centri3 commented Jun 12, 2023

This is reasonable, stuff like u32::default() can be replaced with 0 as well. Though just a thought, maybe this should be a separate lint?

@rustbot label +C-enhancement

@rustbot rustbot added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jun 12, 2023
@Centri3
Copy link
Member

Centri3 commented Jun 18, 2023

I've opened #10985, which should cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

3 participants