-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
default_trait_access should only fire on simple types #5975
Comments
Can you provide example code please? |
Sure! #![deny(clippy::default_trait_access)]
use std::cell::RefCell;
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
struct X {
c: RefCell<HashMap<String, Pin<Box<dyn Future<Output = ()>>>>>
}
fn main() {
let x = X { c: Default::default() };
} gives
|
Thanks! We should add a configuration option where the type depth can be specified. About the |
I think the underlying problem is clippy suggests code with complete parameters, not clippy triggers this lint even for complex types. AFAIK, If code compiles with |
That's a very good observation, thanks! See also #5990 about this. I think the nicest would be to explicitly include all types up to the first type that can be »empty«, i. e. whose |
I don't agree
For
PhantomData
I think I always preferDefault::default()
.The text was updated successfully, but these errors were encountered: