-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat: derive *
for recursive structures
#178
Conversation
22c3430
to
8c53a8d
Compare
...-derive-internal/src/snapshots/borsh_derive_internal__struct_ser__tests__bound_generics.snap
Show resolved
Hide resolved
...erive-internal/src/snapshots/borsh_derive_internal__struct_ser__tests__recursive_struct.snap
Show resolved
Hide resolved
c776a5e
to
782a85f
Compare
782a85f
to
57d8f4f
Compare
02235b8
to
0c16f65
Compare
ce536d1
to
f88a3a8
Compare
a5c34c9
to
a369169
Compare
2e6d815
to
40f45d1
Compare
fe7a701
to
a1be496
Compare
8a912cd
to
32b6ae7
Compare
4c2a078
to
9d445e9
Compare
field: T::Associated, | ||
another: V, | ||
} | ||
|
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.
serde's FindTyParams
code isn't perfect.
In commented example it does the right thing.
In a case, which is synonymous:
struct Parametrized<T, V> where T: TraitName {
field: <T as TraitName>::Associated,
another: V,
}
it produces following expansion
impl<T, V> borsh::ser::BorshSerialize for Parametrized<T, V>
where
T: TraitName,
T: borsh::ser::BorshSerialize,
V: borsh::ser::BorshSerialize,
{
...
which is an error
error[E0277]: the trait bound `<T as TraitName>::Associated: BorshSerialize` is not satisfied
--> src/main.rs:28:10
|
28 | #[derive(BorshSerialize)]
| ^^^^^^^^^^^^^^ the trait `BorshSerialize` is not implemented for `<T as TraitName>::Associated`
|
= note: this error originates in the derive macro `BorshSerialize` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
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.
This is sic!
P.S. I feel we should have killed borsh-schema earlier, so you would not need to spend so much effort implementing it...
|
||
#[cfg_attr( | ||
feature = "force_exhaustive_checks", | ||
deny(non_exhaustive_omitted_patterns) |
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 feel this should be the default configuration for the module of even crate, and explicitly opted-out (allowed) whenever necessary. What do you think?
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 think that it's so in selene's code (where i borrowed it from) due to convention to specify exact nightly features that are going to be used
(probably because some combinations of them can interact/bug in weird ways, and it's hard to test all possible combinations in nightly; like there's more or less only one stable compiler for a version, and there're infinite number of nightly compilers ) ).
My suggestion, is when feature(non_exhaustive_omitted_patterns_lint)
is stabilized, then all of #[cfg_attr(...)]
relevant to it can be removed
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.
If the attribute is removed now, then it becomes less apparent, that the feature is not stable yet.
Well, at least it has some unique quirks, that are more interesting when tried to be implemented than copy-and-paste of functionality from serde ) |
Resolves #7