-
Notifications
You must be signed in to change notification settings - Fork 28
Remove PhantomData #31
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
Conversation
|
Thanks for your prototype.
However, I think we really do need a differerent approach if this approach cannot fix this bug. You approached the biggest limitation of proc. macros in that they cannot access semantic information of the underlying code but just syntactical information which is why you try to filter |
@Robbepop fixed this problem. There might be others ofc, but ptal at your convenience. :) |
|
I'd like to investigate another approach that does not rely on syntactical filtering as in this PR but rather on some way using the Rust type system before we eventually merge this. |
|
I have had a conversation with @ascjones yesterday where we talked about this PR. #[derive(scale_info::TypeInfo)]
pub struct Vec3<T> {
x: i32,
y: i32,
z: i32,
#[scale_info(ignore)]
a: PhantomData<T>,
}However, before we go into design of these proc. macro attributes we first need to figure out what is an appropriate default for this scenario:
I am actually leaning towards the 1. suggestion because it looks cleaner to me all in all even if it is kinda of a slight mismatch with the default behavior that I am expecting in the common case with |
@Robbepop One problem with adding a (The decision to merge the two code bases or not seems non-urgent to me; I suggest we not worry about it for now.) |
|
|
Closing in favor of #48 |
This PR attempts to solve #7 by filtering out all occurrences of
PhantomDataand all type parameters contained by the markers.EDIT: nested tuples now work too.
It is "an attempt" because it ultimately fails to achieve full removal of the markers. In particular, nested tuples are not handled at all, so…works and generates type info equivalent tostruct A { a: (bool) }, but…does not work as expected (the nested tuple is removed completely).I'm leaving this here for future consideration. Maybe the actual use-cases are limited enough that nested tuples aren't ever going to be a problem. Or maybe we need a different approach entirely.