-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 dyn-star #102425
Comments
@rustbot label +C-tracking-issue |
…er-errors Add a test case for async dyn* traits This adds a test case that approximates async functions in dyn traits using `dyn*`. The purpose is to have an example of where we are with `dyn*` and the goal of using it for dyn traits. Issue rust-lang#102425 r? `@compiler-errors`
…sue, r=jackh726 Use the correct tracking issue for `dyn_star` `#![feature(dyn_star)]` now has its own tracking issue, rust-lang#102425.
Currently the dynamic type hidden by |
Right now you can actually place smaller size & align types with |
This is not true for |
Ah, right. I guess a better way to describe the requirements is something like union DynStarCompatible<T> {
true_value: T,
size_align: usize,
} where |
Yes, this is something I would like to support. |
From the initial PR:
Honestly that seems like a shame -- this could be useful way beyond |
might be useful to point out that the post you linked intentionally ignores any non- |
…li-obk Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](rust-lang#106532 (comment)) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) rust-lang#102425
Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](rust-lang/rust#106532 (comment)) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) rust-lang/rust#102425
Maybe "never" was too strong in the original PR. I think |
=== stdout === === stderr === warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/105777.rs:1:12 | 1 | #![feature(dyn_star)] | ^^^^^^^^ | = note: see issue #102425 <rust-lang/rust#102425> for more information = note: `#[warn(incomplete_features)]` on by default warning: 1 warning emitted ==============
=== stdout === === stderr === warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes --> /home/runner/work/glacier/glacier/ices/104631.rs:3:12 | 3 | #![feature(dyn_star)] | ^^^^^^^^ | = note: see issue #102425 <rust-lang/rust#102425> for more information = note: `#[warn(incomplete_features)]` on by default error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer --> /home/runner/work/glacier/glacier/ices/104631.rs:14:13 | 14 | let x = AlignedUsize(12) as dyn* Debug; | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type | = help: the trait `PointerLike` is not implemented for `AlignedUsize` error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0277`. ==============
I doubt that if this needs to be a language feature instead of a library impl. // Or `Dyn: Pointee + ?Sized`, but we'll tolerant non `dyn` unsized types.
pub struct InlinedDyn<Dyn: Pointee<Metadata = ptr::DynMetadata<Dyn>> + ?Sized> {
data: usize, // Or anything if you like, or even with a const generic size.
metadata: ptr::DynMetadata<Dyn>,
_marker: PhantomData<Dyn>,
}
impl<Dyn: Pointee<Metadata = ptr::DynMetadata<Dyn>> + ?Sized> InlinedDyn<Dyn> {
pub fn new<T: Unsize<Dyn>>(value: T) -> Self;
}
impl<Dyn: Pointee<Metadata = ptr::DynMetadata<Dyn>> + ?Sized> ops::Deref for InlinedDyn<Dyn> {
type Target = Dyn;
}
impl<Dyn: Pointee<Metadata = ptr::DynMetadata<Dyn>> + ?Sized> ops::DerefMut for InlinedDyn<Dyn> {} Is there any feature I missed that cannot be implemented like this? |
That doesn't allow coercing to |
Noting here (and left an unchecked checkbox above) that |
That's fair, but I still think a struct-like lang-item is more pretty, just like
Is this really necessary? |
Through an unstable feature to allow unsized arguments that is. Not something that can be replicated by end users for other traits. |
For what it's worth, we consider |
#115699 on the side fixes yet another bug caused by those two being the same TyKind. |
Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](rust-lang/rust#106532 (comment)) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) rust-lang/rust#102425
Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](rust-lang/rust#106532 (comment)) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) rust-lang/rust#102425
This issue tracks known issues or missing functionality with support for
dyn* Trait
objects. These are an experimental feature that are meant to support async function in dyn traits.In addition to the issues linked here, you can also find things that need to be done by greping the code for
// FIXME(dyn-star)
or looking at the F-dyn_star label.dyn*
item to Vec. #102141dyn*
does not support trait upcasting #104800dyn
anddyn*
should (probably?) have their TyKind representation split from one another -- Create a new TyKind::DynStar variant #107908 was an attempt at thisAssociated PRs
About this issue
This is a lang-team experiment -- there hasn't been an RFC for this functionality, we're exploring it both as a potential implementation detail and (more speculatively) a possible language feature in the future. You can read more about dyn* at this blog post.
Lang-team champion: @nikomatsakis
The text was updated successfully, but these errors were encountered: