From bb882d74bd00477395e8d302463148f0a5f8cfe6 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 23 Jun 2020 17:52:01 +0900 Subject: [PATCH 1/4] Add test for issue-44861 --- src/test/ui/specialization/issue-44861.rs | 40 +++++++++++++++++++ src/test/ui/specialization/issue-44861.stderr | 12 ++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/ui/specialization/issue-44861.rs create mode 100644 src/test/ui/specialization/issue-44861.stderr diff --git a/src/test/ui/specialization/issue-44861.rs b/src/test/ui/specialization/issue-44861.rs new file mode 100644 index 0000000000000..c37a6273de366 --- /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::Data); + +pub trait Smartass { + type Data; + type Data2: CoerceUnsized<*const [u8]>; +} + +pub trait MaybeObjectSafe {} + +impl MaybeObjectSafe for () {} + +impl Smartass for T { + type Data = ::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 CoerceUnsized> for SmartassPtr + where ::Data: std::ops::CoerceUnsized<::Data> +{} + +pub fn conv(s: SmartassPtr<()>) -> SmartassPtr { + s +} diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr new file mode 100644 index 0000000000000..b41b17e76a6ab --- /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`. From 43ef554b6ab72c4cc3c56dab8e9b61021c63b3b7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 23 Jun 2020 17:52:26 +0900 Subject: [PATCH 2/4] Add test for issue-51506 --- src/test/ui/never_type/issue-51506.rs | 41 +++++++++++++++++++++++ src/test/ui/never_type/issue-51506.stderr | 14 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/test/ui/never_type/issue-51506.rs create mode 100644 src/test/ui/never_type/issue-51506.stderr diff --git a/src/test/ui/never_type/issue-51506.rs b/src/test/ui/never_type/issue-51506.rs new file mode 100644 index 0000000000000..d0fe6a0f59a87 --- /dev/null +++ b/src/test/ui/never_type/issue-51506.rs @@ -0,0 +1,41 @@ +#![feature(never_type, specialization)] +#![allow(incomplete_features)] + +use std::iter::{self, Empty}; + +trait Trait { + type Out: Iterator; + + fn f(&self) -> Option; +} + +impl Trait for T { + default type Out = !; //~ ERROR: `!` is not an iterator + + default fn f(&self) -> Option { + None + } +} + +struct X; + +impl Trait for X { + type Out = Empty; + + fn f(&self) -> Option { + Some(iter::empty()) + } +} + +fn f(a: T) { + if let Some(iter) = a.f() { + println!("Some"); + for x in iter { + println!("x = {}", x); + } + } +} + +pub fn main() { + f(10); +} diff --git a/src/test/ui/never_type/issue-51506.stderr b/src/test/ui/never_type/issue-51506.stderr new file mode 100644 index 0000000000000..73865a9b5a02c --- /dev/null +++ b/src/test/ui/never_type/issue-51506.stderr @@ -0,0 +1,14 @@ +error[E0277]: `!` is not an iterator + --> $DIR/issue-51506.rs:13:5 + | +LL | type Out: Iterator; + | ------------------------------- required by `Trait::Out` +... +LL | default type Out = !; + | ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `!` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From e817cd2a6e499eebf9674e558b762fd98581f13a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 23 Jun 2020 17:52:42 +0900 Subject: [PATCH 3/4] Add test for issue-59435 --- src/test/ui/specialization/issue-59435.rs | 17 +++++++++++++++++ src/test/ui/specialization/issue-59435.stderr | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/test/ui/specialization/issue-59435.rs create mode 100644 src/test/ui/specialization/issue-59435.stderr diff --git a/src/test/ui/specialization/issue-59435.rs b/src/test/ui/specialization/issue-59435.rs new file mode 100644 index 0000000000000..47323d3096f3d --- /dev/null +++ b/src/test/ui/specialization/issue-59435.rs @@ -0,0 +1,17 @@ +#![feature(specialization)] +#![allow(incomplete_features)] + +struct MyStruct {} + +trait MyTrait { + type MyType: Default; +} + +impl MyTrait for i32 { + default type MyType = MyStruct; + //~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied +} + +fn main() { + let _x: ::MyType = ::MyType::default(); +} diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr new file mode 100644 index 0000000000000..fd512a539a3ee --- /dev/null +++ b/src/test/ui/specialization/issue-59435.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied + --> $DIR/issue-59435.rs:11:5 + | +LL | type MyType: Default; + | --------------------- required by `MyTrait::MyType` +... +LL | default type MyType = MyStruct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From 814782b4c6bd773d47dfce5614d4bbea935f5d85 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 23 Jun 2020 17:52:51 +0900 Subject: [PATCH 4/4] Add test for issue-69840 --- src/test/ui/impl-trait/issue-69840.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/ui/impl-trait/issue-69840.rs diff --git a/src/test/ui/impl-trait/issue-69840.rs b/src/test/ui/impl-trait/issue-69840.rs new file mode 100644 index 0000000000000..b270f88b6886e --- /dev/null +++ b/src/test/ui/impl-trait/issue-69840.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(impl_trait_in_bindings)] +#![allow(incomplete_features)] + +struct A<'a>(&'a ()); + +trait Trait {} + +impl Trait for () {} + +pub fn foo<'a>() { + let _x: impl Trait> = (); +} + +fn main() {}