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`.