-
Notifications
You must be signed in to change notification settings - Fork 150
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
Ns/fix/versionable bad bounds #1551
Conversation
2ebd7b0
to
f1548d1
Compare
a7628ea
to
b0c32a9
Compare
Over-restrictive derived bounds were in some cases unsatisfiable, making the `versionize` method uncallable. BREAKING_CHANGE: - The `#[versionize(bound = ...)]` attribute is not needed anymore, so it has been removed.
b0c32a9
to
2e8c436
Compare
For reference, the rust std lib and serde have the same problem this PR is trying to solve: rust-lang/rust#26925.
It looks like 1. has been fixed on the compiler side and does not raise an error anymore. I will try to test 2 and 3 but I think that if they still fail we should adopt this PR. The macros of |
I have done a few tests on these issues:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't pretend I understand everything that's going on, but the assurance it works with the test runs gives reassurance on that end (and the fact our lib and others are using this successfully)
some small stuff I saw
Mostly test in the main that the derived code actually works
5900abc
to
d2830e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
needed by: #1482
PR content/description
Fix the bounds added in the derived traits for the Versionize macro. These bounds were too restrictive and there were cases where they were not satisfiable, so the
versionize
method on a type was actually not callable. This was the case for example when a type was defined with a generic that is not itself used, but only through associated types. For example:Using the
#[derive(Versionize)]
on this type before the PR would requireT: Versionize
which is actually not necessary and sometimes not possible. This was caused by the proc macro trying to apply bounds directly on the generics of the type.The main idea behind this PR is to add bounds closer to what is actually used, and not necessarily to the generics. For example, If I have 3 traits:
and these 2 types:
I have 2 ways of expressing the bound:
impl<T: TraitA> TraitC for Type2<T>
impl<T> TraitC for Type2<T> where Type1<T>: TraitB
This PR works by using the second method instead of the first one. The advantage is that theses bounds are easier to generate by looking only at
Type2
, without knowing the internals ofType1
.As a side effect, the
#[versionize(..., bound = "...")]
attribute for the proc macro is not necessary anymore to express the bounds present in tfhe-rs, so it have been removed. This is a breaking change. There might still be specific corner cases that will require it, but as I don't have any example to test it I preferred to removed it.This PR also adds the versioning of vector of small tuples of arbitrary versioned types.
Check-list: