summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/impl-trait/impl-subtyper.rs18
-rw-r--r--tests/ui/impl-trait/impl-subtyper2.rs7
-rw-r--r--tests/ui/type-alias-impl-trait/normalize-alias-type.rs32
-rw-r--r--tests/ui/type-alias-impl-trait/tait-normalize.rs14
-rw-r--r--tests/ui/type/subtyping-opaque-type.rs19
5 files changed, 90 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/impl-subtyper.rs b/tests/ui/impl-trait/impl-subtyper.rs
new file mode 100644
index 00000000000..2d99cdd4f50
--- /dev/null
+++ b/tests/ui/impl-trait/impl-subtyper.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![crate_type = "lib"]
+fn checkpoints() -> impl Iterator {
+    Some(()).iter().flat_map(|_| std::iter::once(()))
+}
+
+fn block_checkpoints() -> impl Iterator {
+    checkpoints()
+}
+
+fn iter_raw() -> impl Iterator {
+    let mut iter = block_checkpoints();
+
+    (0..9).map(move |_| {
+        iter.next();
+    })
+}
diff --git a/tests/ui/impl-trait/impl-subtyper2.rs b/tests/ui/impl-trait/impl-subtyper2.rs
new file mode 100644
index 00000000000..2e0acbae68b
--- /dev/null
+++ b/tests/ui/impl-trait/impl-subtyper2.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+fn ages() -> Option<impl Iterator> {
+    None::<std::slice::Iter<()>>
+}
+
+fn main(){}
diff --git a/tests/ui/type-alias-impl-trait/normalize-alias-type.rs b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs
new file mode 100644
index 00000000000..7c62002b931
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs
@@ -0,0 +1,32 @@
+// check-pass
+// compile-flags: -Z mir-opt-level=3
+#![feature(type_alias_impl_trait)]
+#![crate_type = "lib"]
+pub trait Tr {
+    fn get(&self) -> u32;
+}
+
+impl Tr for (u32,) {
+    #[inline]
+    fn get(&self) -> u32 { self.0 }
+}
+
+pub fn tr1() -> impl Tr {
+    (32,)
+}
+
+pub fn tr2() -> impl Tr {
+    struct Inner {
+        x: X,
+    }
+    type X = impl Tr;
+    impl Tr for Inner {
+        fn get(&self) -> u32 {
+            self.x.get()
+        }
+    }
+
+    Inner {
+        x: tr1(),
+    }
+}
diff --git a/tests/ui/type-alias-impl-trait/tait-normalize.rs b/tests/ui/type-alias-impl-trait/tait-normalize.rs
new file mode 100644
index 00000000000..26d94dbb42a
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/tait-normalize.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+fn enum_upvar() {
+    type T = impl Copy;
+    let foo: T = Some((1u32, 2u32));
+    let x = move || match foo {
+        None => (),
+        Some((a, b)) => (),
+    };
+}
+
+fn main(){}
diff --git a/tests/ui/type/subtyping-opaque-type.rs b/tests/ui/type/subtyping-opaque-type.rs
new file mode 100644
index 00000000000..beda232ea8b
--- /dev/null
+++ b/tests/ui/type/subtyping-opaque-type.rs
@@ -0,0 +1,19 @@
+// check-pass
+// compile-flags: -Zvalidate-mir
+trait Duh {}
+
+impl Duh for i32 {}
+
+trait Trait {
+    type Assoc: Duh;
+}
+
+impl<R: Duh, F: FnMut() -> R> Trait for F {
+    type Assoc = R;
+}
+
+fn foo() -> impl Trait<Assoc = impl Send> {
+    || 42
+}
+
+fn main() {}