Skip to content

Implement PhantomData #1127

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

Closed
Tracked by #1247
bjorn3 opened this issue Apr 18, 2022 · 2 comments · Fixed by #1633
Closed
Tracked by #1247

Implement PhantomData #1127

bjorn3 opened this issue Apr 18, 2022 · 2 comments · Fixed by #1633

Comments

@bjorn3
Copy link

bjorn3 commented Apr 18, 2022

This is the full definition:

#[lang = "phantom_data"]
pub struct PhantomData<T: ?Sized>;

PhantomData is a ZST, but in all other aspects it behaves as if it contains a value of type T. For example wrt to variance. It also counts as a use of a generic parameter and thus allows disabling the error that generic parameters need to be used.

@liushuyu
Copy link
Contributor

I think this issue could be tagged good-first-pr since a naive implementation (which does not actually check whether the annotated type is really a ZST) is pretty straightforward.

Hints for new contributors: Check this pull request: #1100.

@tamaroning
Copy link
Contributor

Hi, I want to take a shot at this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants