-
Notifications
You must be signed in to change notification settings - Fork 14
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
Think about how to handle Self
bounds on methods
#11
Comments
I guess the issue is how the macro attribute can scale to accommodate other kinds of bounds on the impl target, like adding the For the One option to widen support could be to just accept more of the impl in the #[auto_impl(<'a, T: ?Sized + Clone> &'a T)]
#[auto_impl(<T> Box<T>)]
trait SomeTrait { ... } But then we get into the territory of figuring out what kind of impl we're looking at and whether we need to add additional bounds to It seems like a shame to be limiting in the face of what are pretty common needs, it would be nice if we could find a syntax for |
Good point, I guess that would work. Regarding the main problem: I think I'm against giving the user too many configurations. I think this crate is a crate for 95% of all cases. I don't think it's a problem when the remaining 5% need to be coded by hand. And in particular, including something like Also: the Right now, I think that I would always just add all |
Yeh I agree with this. Otherwise we'd end up in configuration soup very quickly and it'd be a nightmare to maintain and use. I'll open up a separate issue for the auto |
It's only impossible when there is `Self` by value in in parameter or return position in any method. This commit does not yet check for `Self` in non-receiver parameters as this crate cannot deal with that yet anyway. Furthermore, a `where Self: Sized` bound on methods does not help in that we still cannot add the `?Sized` relaxation. This is related to issue #11.
Fixed in #54 |
I encountered a problematic situation where a trait method has a
Self
bound.Which results in:
Ok, that makes sense, but what should we do about it? We cannot add the bound
T: Clone
to the method as this will result in "impl has stricter requirements than trait". We can add aT: Clone
bound to theimpl
block, but this restricts theimpl
a lot. The methodone()
should be callable on&T where T: Foo
, even ifT
doesn't implementClone
.However, I cannot think of any real solution to this (not even related to this crate, but I simply can't think of a way how to impl
Foo
for references in a general way). So I guess we just need to add the bound to theimpl
. If the user has a better solution, they have to write theimpl
for&T
themselves, as this requires logic that we cannot derive from the trait definition.The text was updated successfully, but these errors were encountered: