-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Tracking Issue for #![feature(phantom_variance_markers)]
#135806
Comments
Implement phantom variance markers ACP accepted rust-lang/libs-team#488 Tracking issue rust-lang#135806
As a note for future consideration: since lifetimes are not types, it's somewhat arbitrary to say whether e.g. Stabilizing all of the current names would lock in the choice. (Which may be fine, but should be a conscious decision.) ((The |
Maybe we should try to come up with some new terminology if it's arbitrary anyway? I have heard people say they have to look up what covariant and contravariant mean (in terms of lifetime) every single time because it can be hard to keep in ones head. |
Implement phantom variance markers ACP accepted rust-lang/libs-team#488 Tracking issue rust-lang#135806
Rollup merge of rust-lang#135807 - jhpratt:phantom-variance, r=Amanieu Implement phantom variance markers ACP accepted rust-lang/libs-team#488 Tracking issue rust-lang#135806
Just ran into a slight hiccup with this feature: using these marker types in a Example (playground): #![feature(phantom_variance_markers)]
use std::marker::PhantomCovariantLifetime;
use std::ptr::NonNull;
#[repr(transparent)]
pub struct Foo<'a, T> {
inner: NonNull<T>,
_marker: PhantomCovariantLifetime<'a>,
} warning: zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types
--> src/lib.rs:9:5
|
9 | _marker: PhantomCovariantLifetime<'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
= note: this struct contains `PhantomCovariantLifetime<'a>`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
= note: `#[warn(repr_transparent_external_private_fields)]` on by default
warning: `playground` (lib) generated 1 warning |
😔 some day we'll get |
We do have |
Thanks @lukas-code — I'll get to that tonight 👍 |
Apparently I forgot to mark them |
Implement phantom variance markers ACP accepted rust-lang/libs-team#488 Tracking issue rust-lang#135806
Feature gate:
#![feature(phantom_variance_markers)]
This is a tracking issue for phantom variance markers, which are identical to
PhantomData
but provide a self-documenting variance rather than contrived types such asPhantomData<fn() -> T>
to indicate contravariance.Public API
Steps / History
Unresolved Questions
Lifetime
type or one for each possible variance? The former would mean writingPhantomCovariant<Lifetime<'a>>
instead ofPhantomCovariantLifetime<'a>
, with the API otherwise being identical.::new()
? This would presumably mean adding 4–6 lang items, depending on the previous bullet point.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: