-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: add generic TypeBoundList
in generated derivable impl
#13763
Conversation
292c6a1
to
f2fdfa0
Compare
@lowr The new testcase (against the original example in #13727) works alright now. However, this fix also influences the following test, which got me thinking: maybe enum Generic<T, U: Clone> { One(T), Two(U) }
- impl<T, U: Clone> From<T> for Generic<T, U> {
+ impl<T: From<T>, U: Clone + From<T>> From<T> for Generic<T, U> {
fn from(v: T) -> Self {
Self::One(v)
}
} ... (I guess in this case of Update: I finally special-cased Update: The special-casing of |
1b5a2f5
to
5da97bb
Compare
5da97bb
to
3c196d5
Compare
Hmm, Also, could you add a test case where type parameter(s) already has some bounds so we ensure we don't lose the existing bounds? We may also want to check if the bounds already include the trait we're adding so it wouldn't be duplicated. |
@lowr Thanks a lot for your reply! However, there are still several points that I'm unsure about:
|
3c196d5
to
12b05d2
Compare
I meant you can add the bounds in
That said, cece895 actually looks good enough (though special casing
Aha, this is clearly my oversight, sorry about that. Nice work! 👍 |
@lowr I see what you mean now, thanks 🙏 Let's wait for the moment and see what the maintainers have to say about this change then. Update:
I also updated the code so that it won't special-case |
cece895
to
7c23b7c
Compare
7c23b7c
to
cfa9149
Compare
This seems fine to me, a more general API would be in having the boolean parameter be replaced with a list of bound lists that zip up with the generic parameters, but as that is currently not really needed there is no point in going that far. |
☀️ Test successful - checks-actions |
Potentially fixes #13727.
Continuing with the work in #13732, this fix tries to add correct type bounds in the generated
impl
block: