From 77e88a7c7afce2389b16b385f494be2f836c43ff Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 29 Jun 2022 08:27:14 +0000 Subject: [PATCH] Add more tests --- .../ui/lazy-type-alias-impl-trait/branches.rs | 14 ++++++++++++-- .../lazy-type-alias-impl-trait/branches.stderr | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/lazy-type-alias-impl-trait/branches.stderr 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` + | + = 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>(self) -> B + | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`.