-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement variance RFC #738 #22286
Implement variance RFC #738 #22286
Conversation
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
r? @pnkfelix has been my go-to variance guy. |
Grr, something in the last rebase started causing some (minor looking) test failures. I'll track those down. |
@@ -96,7 +96,7 @@ pub struct Arena<'longer_than_self> { | |||
head: RefCell<Chunk>, | |||
copy_head: RefCell<Chunk>, | |||
chunks: RefCell<Vec<Chunk>>, | |||
_invariant: marker::InvariantLifetime<'longer_than_self>, | |||
_marker: marker::PhantomData<*mut &'longer_than_self()>, |
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.
Space after lifetime name is missing ?
a325f07
to
d910931
Compare
Rebased. Make check passes locally now. |
Needs a rebase |
d910931
to
048359c
Compare
/// FIXME. Better documentation needed here! | ||
#[cfg(not(stage0))] | ||
#[lang="phantom_data"] | ||
pub struct PhantomData<T:?Sized>; |
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.
Could you go ahead an mark this #[stable]
as well? I think it'd been debated enough that it's probably earned it. (you may want to leave PhantomFn
explicitly #[unstable]
for now though).
@nikomatsakis okay i'm done with the review. Some nits and minor questions, but I would not object to you telling bors that this PR as-is is |
into variance inference; fix various bugs in variance inference so that it considers the correct set of constraints; modify infer to consider the results of variance inference for type arguments.
variance or an associated type.
…nd ownership, and also follows the API of `NonZero` a bit more closely. More to do here I think (including perhaps a new name).
here. Some of this may have been poorly rebased, though I tried to be careful and preserve the spirit of the test.
be migrated to an associated type anyway.
048359c
to
9f8b9d6
Compare
@bors: r=pnkfelix 9f8b9d6 |
Conflicts: src/librustc/middle/infer/combine.rs src/librustc_typeck/check/wf.rs
This was merged in #22541 |
This PR:
PhantomData
/PhantomFn
scheme;This is a [breaking-change]:
PhantomData
. It is possible to simulate all of the old markers:ContravariantLifetime<'a>
->PhantomData<&'a ()>
(or just&'a ()
, actually)InvariantLifetime<'a>
->PhantomData<Cell<&'a ()>>
CovariantType<T>
->PhantomData<T>
ContravariantType<T>
->PhantomData<fn(T)>
InvariantType<T>
->PhantomData<Cell<T>>
PhantomData
to your struct (orPhantomFn
/MarkerTrait
to your trait). See Support variance for type parameters rfcs#738 for more background.Fixes #22212.