diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-06-23 17:52:01 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-06-23 17:52:01 +0900 |
| commit | bb882d74bd00477395e8d302463148f0a5f8cfe6 (patch) | |
| tree | 112061699c57c60185147fd4b7865cc26491865b | |
| parent | 3b1c08c68ccc2c222f84384c836b5e167e2bc241 (diff) | |
| download | rust-bb882d74bd00477395e8d302463148f0a5f8cfe6.tar.gz rust-bb882d74bd00477395e8d302463148f0a5f8cfe6.zip | |
Add test for issue-44861
| -rw-r--r-- | src/test/ui/specialization/issue-44861.rs | 40 | ||||
| -rw-r--r-- | src/test/ui/specialization/issue-44861.stderr | 12 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/ui/specialization/issue-44861.rs b/src/test/ui/specialization/issue-44861.rs new file mode 100644 index 00000000000..c37a6273de3 --- /dev/null +++ b/src/test/ui/specialization/issue-44861.rs @@ -0,0 +1,40 @@ +#![crate_type = "lib"] +#![feature(specialization)] +#![feature(unsize, coerce_unsized)] +#![allow(incomplete_features)] + +use std::ops::CoerceUnsized; + +pub struct SmartassPtr<A: Smartass+?Sized>(A::Data); + +pub trait Smartass { + type Data; + type Data2: CoerceUnsized<*const [u8]>; +} + +pub trait MaybeObjectSafe {} + +impl MaybeObjectSafe for () {} + +impl<T> Smartass for T { + type Data = <Self as Smartass>::Data2; + default type Data2 = (); + //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied +} + +impl Smartass for () { + type Data2 = *const [u8; 1]; +} + +impl Smartass for dyn MaybeObjectSafe { + type Data = *const [u8]; + type Data2 = *const [u8; 0]; +} + +impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U> + where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data> +{} + +pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> { + s +} diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr new file mode 100644 index 00000000000..b41b17e76a6 --- /dev/null +++ b/src/test/ui/specialization/issue-44861.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied + --> $DIR/issue-44861.rs:21:5 + | +LL | type Data2: CoerceUnsized<*const [u8]>; + | --------------------------------------- required by `Smartass::Data2` +... +LL | default type Data2 = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
