about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-06-29 08:27:14 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-06-29 08:58:36 +0000
commit77e88a7c7afce2389b16b385f494be2f836c43ff (patch)
tree9d17c2de4975f658d24f2b52d4c5c83cd6c3cd54
parent524d2b3178c7fab77894b942f328abb32f6b2776 (diff)
downloadrust-77e88a7c7afce2389b16b385f494be2f836c43ff.tar.gz
rust-77e88a7c7afce2389b16b385f494be2f836c43ff.zip
Add more tests
-rw-r--r--src/test/ui/lazy-type-alias-impl-trait/branches.rs14
-rw-r--r--src/test/ui/lazy-type-alias-impl-trait/branches.stderr16
2 files changed, 28 insertions, 2 deletions
diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.rs b/src/test/ui/lazy-type-alias-impl-trait/branches.rs
index e7db10bd7cd..95239e2e341 100644
--- a/src/test/ui/lazy-type-alias-impl-trait/branches.rs
+++ b/src/test/ui/lazy-type-alias-impl-trait/branches.rs
@@ -1,7 +1,5 @@
 #![feature(type_alias_impl_trait)]
 
-// check-pass
-
 type Foo = impl std::fmt::Debug;
 
 fn foo(b: bool) -> Foo {
@@ -12,4 +10,16 @@ fn foo(b: bool) -> Foo {
     }
 }
 
+type Bar = impl std::fmt::Debug;
+
+fn bar(b: bool) -> Bar {
+    let x: Bar = if b {
+        vec![42_i32]
+    } else {
+        std::iter::empty().collect()
+        //~^ ERROR  a value of type `Bar` cannot be built from an iterator over elements of type `_`
+    };
+    x
+}
+
 fn main() {}
diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.stderr b/src/test/ui/lazy-type-alias-impl-trait/branches.stderr
new file mode 100644
index 00000000000..6b87da0c040
--- /dev/null
+++ b/src/test/ui/lazy-type-alias-impl-trait/branches.stderr
@@ -0,0 +1,16 @@
+error[E0277]: a value of type `Bar` cannot be built from an iterator over elements of type `_`
+  --> $DIR/branches.rs:19:28
+   |
+LL |         std::iter::empty().collect()
+   |                            ^^^^^^^ value of type `Bar` cannot be built from `std::iter::Iterator<Item=_>`
+   |
+   = help: the trait `FromIterator<_>` is not implemented for `Bar`
+note: required by a bound in `collect`
+  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+   |
+LL |     fn collect<B: FromIterator<Self::Item>>(self) -> B
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.