From ca722b935835f7ce3acfbb840141cc17941fc63b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 25 May 2020 22:29:06 +0900 Subject: [PATCH 1/4] Add test for #56445 --- src/test/ui/impl-trait/issue-56445.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/ui/impl-trait/issue-56445.rs diff --git a/src/test/ui/impl-trait/issue-56445.rs b/src/test/ui/impl-trait/issue-56445.rs new file mode 100644 index 0000000000000..a34d7bae3a6ca --- /dev/null +++ b/src/test/ui/impl-trait/issue-56445.rs @@ -0,0 +1,26 @@ +// Regression test for /~https://github.com/rust-lang/rust/issues/56445#issuecomment-629426939 +// check-pass + +#![crate_type = "lib"] + +use std::marker::PhantomData; + +pub struct S<'a> +{ + pub m1: PhantomData<&'a u8>, + pub m2: [u8; S::size()], +} + +impl<'a> S<'a> +{ + pub const fn size() -> usize { 1 } + + pub fn new() -> Self + { + Self + { + m1: PhantomData, + m2: [0; Self::size()], + } + } +} From 125f0abb42159d3db9d86208e03006d068585bbf Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 25 May 2020 22:29:25 +0900 Subject: [PATCH 2/4] Add test for #68532 --- src/test/ui/impl-trait/issue-68532.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/ui/impl-trait/issue-68532.rs diff --git a/src/test/ui/impl-trait/issue-68532.rs b/src/test/ui/impl-trait/issue-68532.rs new file mode 100644 index 0000000000000..01a7af0aee40e --- /dev/null +++ b/src/test/ui/impl-trait/issue-68532.rs @@ -0,0 +1,13 @@ +// check-pass + +pub struct A<'a>(&'a ()); + +impl<'a> A<'a> { + const N: usize = 68; + + pub fn foo(&self) { + let _b = [0; Self::N]; + } +} + +fn main() {} From 4b87f97ca8862ad97272ecafcd4c27334ecb81aa Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 25 May 2020 22:29:34 +0900 Subject: [PATCH 3/4] Add test for #70121 --- .../ui/type-alias-impl-trait/issue-70121.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/ui/type-alias-impl-trait/issue-70121.rs diff --git a/src/test/ui/type-alias-impl-trait/issue-70121.rs b/src/test/ui/type-alias-impl-trait/issue-70121.rs new file mode 100644 index 0000000000000..dff0d89d465dd --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-70121.rs @@ -0,0 +1,23 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +pub type Successors<'a> = impl Iterator; + +pub fn f<'a>() -> Successors<'a> { + None.into_iter() +} + +pub trait Tr { + type Item; +} + +impl<'a> Tr for &'a () { + type Item = Successors<'a>; +} + +pub fn kazusa<'a>() -> <&'a () as Tr>::Item { + None.into_iter() +} + +fn main() {} From 6315d0c99eead181e3725623c6a9d01950620640 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 27 May 2020 00:48:29 +0900 Subject: [PATCH 4/4] Add test for #71042 --- ...ssue-71042-opaquely-typed-constant-used-in-pattern.rs | 9 +++++++++ ...-71042-opaquely-typed-constant-used-in-pattern.stderr | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs create mode 100644 src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr diff --git a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs new file mode 100644 index 0000000000000..c5e4a72fb9ff1 --- /dev/null +++ b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs @@ -0,0 +1,9 @@ +#![feature(impl_trait_in_bindings)] +#![allow(incomplete_features)] + +fn main() { + const C: impl Copy = 0; + match C { + C | _ => {} //~ ERROR: opaque types cannot be used in patterns + } +} diff --git a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr new file mode 100644 index 0000000000000..7695223f2cf98 --- /dev/null +++ b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr @@ -0,0 +1,8 @@ +error: opaque types cannot be used in patterns + --> $DIR/issue-71042-opaquely-typed-constant-used-in-pattern.rs:7:9 + | +LL | C | _ => {} + | ^ + +error: aborting due to previous error +