Add more tests

This commit is contained in:
Oli Scherer 2022-06-29 08:27:14 +00:00
parent 524d2b3178
commit 77e88a7c7a
2 changed files with 28 additions and 2 deletions

View File

@ -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() {}

View File

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