Skip to content

Commit 77e88a7

Browse files
committed
Add more tests
1 parent 524d2b3 commit 77e88a7

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/test/ui/lazy-type-alias-impl-trait/branches.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(type_alias_impl_trait)]
22

3-
// check-pass
4-
53
type Foo = impl std::fmt::Debug;
64

75
fn foo(b: bool) -> Foo {
@@ -12,4 +10,16 @@ fn foo(b: bool) -> Foo {
1210
}
1311
}
1412

13+
type Bar = impl std::fmt::Debug;
14+
15+
fn bar(b: bool) -> Bar {
16+
let x: Bar = if b {
17+
vec![42_i32]
18+
} else {
19+
std::iter::empty().collect()
20+
//~^ ERROR a value of type `Bar` cannot be built from an iterator over elements of type `_`
21+
};
22+
x
23+
}
24+
1525
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: a value of type `Bar` cannot be built from an iterator over elements of type `_`
2+
--> $DIR/branches.rs:19:28
3+
|
4+
LL | std::iter::empty().collect()
5+
| ^^^^^^^ value of type `Bar` cannot be built from `std::iter::Iterator<Item=_>`
6+
|
7+
= help: the trait `FromIterator<_>` is not implemented for `Bar`
8+
note: required by a bound in `collect`
9+
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
10+
|
11+
LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)