-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Open
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.This change is large or controversial enough that it should have an RFC accepted before doing it.
Description
This came up in the fix for #48493. It seems like unions should have unsize impls for all of their fields?
#![feature(untagged_unions, unsize, coerce_unsized)]
use std::marker::Unsize;
use std::ops::CoerceUnsized;
union Data<T: ?Sized> {
v: T,
u: (),
}
struct Pointer<T: ?Sized>(Box<Data<T>>);
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Pointer<U>> for Pointer<T> {}
fn main() {}error[E0277]: the trait bound `Data<T>: std::marker::Unsize<Data<U>>` is not satisfied
--> src/main.rs:12:1
|
12 | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Pointer<U>> for Pointer<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unsize<Data<U>>` is not implemented for `Data<T>`
|
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<Data<U>>>` for `std::boxed::Box<Data<T>>`
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0277"
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.This change is large or controversial enough that it should have an RFC accepted before doing it.