diff options
| author | b-naber <bn263@gmx.de> | 2021-12-02 20:30:35 +0100 |
|---|---|---|
| committer | b-naber <bn263@gmx.de> | 2021-12-02 23:27:08 +0100 |
| commit | a11994e4230c777a5fbcc3bb1cc080903e7c1664 (patch) | |
| tree | 8a100b3e4f9fc6880714b9dc585e221e51bd35e9 /src | |
| parent | d9baa361902b172be716f96619b909f340802dea (diff) | |
use try_normalize_erasing_regions in needs_drop
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/union/issue-81199.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/union/issue-81199.stderr | 29 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/test/ui/union/issue-81199.rs b/src/test/ui/union/issue-81199.rs new file mode 100644 index 00000000000..628e7c6ed5d --- /dev/null +++ b/src/test/ui/union/issue-81199.rs @@ -0,0 +1,21 @@ +#[repr(C)] +union PtrRepr<T: ?Sized> { + const_ptr: *const T, + mut_ptr: *mut T, + components: PtrComponents<T>, + //~^ ERROR the trait bound +} + +#[repr(C)] +struct PtrComponents<T: Pointee + ?Sized> { + data_address: *const (), + metadata: <T as Pointee>::Metadata, +} + + + +pub trait Pointee { + type Metadata; +} + +fn main() {} diff --git a/src/test/ui/union/issue-81199.stderr b/src/test/ui/union/issue-81199.stderr new file mode 100644 index 00000000000..f26bfe3a0b0 --- /dev/null +++ b/src/test/ui/union/issue-81199.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `T: Pointee` is not satisfied in `PtrComponents<T>` + --> $DIR/issue-81199.rs:5:17 + | +LL | components: PtrComponents<T>, + | ^^^^^^^^^^^^^^^^ within `PtrComponents<T>`, the trait `Pointee` is not implemented for `T` + | +note: required because it appears within the type `PtrComponents<T>` + --> $DIR/issue-81199.rs:10:8 + | +LL | struct PtrComponents<T: Pointee + ?Sized> { + | ^^^^^^^^^^^^^ + = note: no field of a union may have a dynamically sized type + = help: change the field's type to have a statically known size +help: consider further restricting this bound + | +LL | union PtrRepr<T: ?Sized + Pointee> { + | +++++++++ +help: borrowed types always have a statically known size + | +LL | components: &PtrComponents<T>, + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | components: Box<PtrComponents<T>>, + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
