-
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
box-default wrongly suggest on dyn trait #9621
Comments
@rustbot claim I think it should still work with |
Consider this artifical example: trait MyTrait {}
#[derive(Default)]
struct MyStruct;
impl MyTrait for MyStruct {}
fn take_box_dyn(_: Box<dyn MyTrait>) {}
fn main() {
let _: Box<dyn MyTrait> = Box::new(MyStruct::default());
take_box_dyn(Box::new(MyStruct::default()));
} Clippy says this:
So, for a variable of type
|
I have same problem: box to dyn trait and clippy suggest variant with Box::default(), which can't compiled. |
Same on the latest nightly - this issue is only partially fixed. |
I'm having an issue with a crate that provides a builder-pattern "default" function and clippy is complaining about it, even though the object does not (and cannot) implement Default. I'm silencing the warning for now. |
@rwthompsonii can you provide code? |
It's closed source, I'll try and get an unencumbered example tomorrow. |
Summary
I have a function signature like
fn with_bar(self, bar: Box<dyn Bar>)
, andbox-default
will suggestFoo::new().with_bar(Box::default())
overFoo::new().with_bar(Box::new(BarImpl::default))
, which clearly cannot be compiled.Lint Name
box-default
Reproducer
No response
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: