-
Notifications
You must be signed in to change notification settings - Fork 123
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
Redundant bound for Debug on skipped field/make display(bound) do the same as debug(bound) #281
Comments
I wonder if (this would need to happen before 1.0) we could have:
Syntax was inspired by |
The 1. behavior could be extended with some heuristics checking for usages of the generic, i.e. remove the bound if it is only used in skipped fields. But this is more complex and I don't know if we can do this reliably. |
@JelteF |
Maybe bounds should be handled somewhat centrally, i.e. the same for all traits. I think we could, have a struct, that takes:
Afterwards, we call some "get impl generics" on this bound handler that returns the generics we can use in the impl trait signature. |
@ModProg I'm not a fan on |
agreed, the idea is to impose only bounds, that are 100% required and then add missing ones with |
From what I see in code docs, the current behavior is:
We cannot actually change the way it works for |
What do we do on generics of field types? i.e. We can hard code them, but that is problematic, as anyone can add their own type that does or does not have a bound on their generics. I'd like the default behavior to be matching the std, i.e. add bounds on generics that are in fields that are used, so you don't need to add a But I'd be fine with having |
That sounds bad in my opinion, the behavior should be identical over all traits. |
We could also have a |
We do not bound type parameters blindly as
I don't see any problems with that. Making The interesting question here is whether making |
@tyranron, yeah, sorry I was under the false impression
I don't think so, my case presented earlier only applies to the
They do, but they have exactly the same syntax on I think the main issue from my side was the false impression that |
What do you think on that? It really seems that we can change the "replacing" strategy to "adding" in |
## Synopsis > ```rs > struct NoDebug; > > #[derive(derive_more::Debug)] > struct HasDebug<T>(#[debug(skip)] T); > > dbg!(HasDebug(NoDebug)); > ``` > > I'd be fine with needing to manually specify something like `#[debug(bounds())]`. ## Solution Fix how `ignore`/`skip` attributes are considered in bounding of `derive(Debug)` macro.
Keeping it open until we decide on the question above. |
Maybe should rename the issue? |
ping @JelteF |
Okay read the thread. I agree let's make this consistent and only have |
cc @MegaBluejay please, do after finishing all the stuff with |
## Synopsis The docs for the `Display` derive state that explicitly specified bounds replace the auto-inferred ones, when this is actually not the case. There's also some outdated information about what's allowed in `#[display(bound(...)]` arguments, and incorrect example of the generated `where` clause. ## Solution Update the `Display` docs with actual information.
I'd be fine with needing to manually specify something like
#[debug(bounds())]
.The text was updated successfully, but these errors were encountered: