Skip to content
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

Add Gankro's table to nomicon/src/phantom-data.md #40069

Merged
merged 1 commit into from
Feb 25, 2017

Conversation

Rufflewind
Copy link
Contributor

@Rufflewind Rufflewind commented Feb 24, 2017

Original: #30069 (comment)

Testing confirms that:

  • PhantomData<fn() -> T> does not actually enable drop checking.
  • PhantomData<fn(T) -> T> is neither variant nor contravariant.

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@steveklabnik
Copy link
Member

@bors: r+

neat, thank you! ❤️

@bors
Copy link
Contributor

bors commented Feb 24, 2017

📌 Commit 49fa66c has been approved by steveklabnik

@bluss
Copy link
Member

bluss commented Feb 24, 2017

@pnkfelix Does PhantomData<T> have a special role in drop checking now? If we compare with PhantomData<*const T>, don't both those have the same drop check implications nowadays?

@Rufflewind
Copy link
Contributor Author

This is what I used to test whether the drop checker is active:

use std::marker::PhantomData;

struct Inspector<'a>(&'a ());

impl<'a> Drop for Inspector<'a> {
    fn drop(&mut self) {}
}

fn wrap<T>(_: T) -> PhantomData<T> { PhantomData }

fn main() {
    let (i, inspector);
    i = ();
    inspector = wrap(Inspector(&i));
}

Right now this fails to compile. But if I use PhantomData<*const T> then it compiles successfully.

@bluss
Copy link
Member

bluss commented Feb 25, 2017

Nice!

You said:

PhantomData<fn() -> T> does enable drop checking.

The code doesn't demonstrate this, did you mean the opposite?

@Rufflewind
Copy link
Contributor Author

The code doesn't demonstrate this, did you mean the opposite?

Yeah, I meant the opposite. The documentation is correct, but I messed up the commit message / pull request -.-

Rebasing…

Original: rust-lang#30069 (comment)

Testing confirms that:

  - PhantomData<fn() -> T> does not actually enable drop checking.
  - PhantomData<fn(T) -> T> is neither variant nor contravariant.
@steveklabnik
Copy link
Member

@bors: r+ rollup

nice catch all, sorry I missed it! 😓

@bors
Copy link
Contributor

bors commented Feb 25, 2017

📌 Commit 1f75085 has been approved by steveklabnik

eddyb added a commit to eddyb/rust that referenced this pull request Feb 25, 2017
Add Gankro's table to nomicon/src/phantom-data.md

Original: rust-lang#30069 (comment)

Testing confirms that:

  - `PhantomData<fn() -> T>` does not actually enable drop checking.
  - `PhantomData<fn(T) -> T>` is neither variant nor contravariant.
@bluss
Copy link
Member

bluss commented Feb 25, 2017

Thanks for the clarification and the new and better docs!

eddyb added a commit to eddyb/rust that referenced this pull request Feb 25, 2017
Add Gankro's table to nomicon/src/phantom-data.md

Original: rust-lang#30069 (comment)

Testing confirms that:

  - `PhantomData<fn() -> T>` does not actually enable drop checking.
  - `PhantomData<fn(T) -> T>` is neither variant nor contravariant.
bors added a commit that referenced this pull request Feb 25, 2017
@bors bors merged commit 1f75085 into rust-lang:master Feb 25, 2017
@Rufflewind Rufflewind deleted the master branch March 19, 2017 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants