Add ui test for E0271 error

This commit is contained in:
Obei Sideg 2023-02-20 15:43:55 +03:00
parent b93d54556f
commit 99344a8b32
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,13 @@
fn foo(items: &mut Vec<u8>) {
items.sort();
}
fn bar() -> impl Iterator<Item = i32> {
//~^ ERROR expected `foo` to be a fn item that returns `i32`, but it returns `()` [E0271]
let mut x: Vec<Vec<u8>> = vec![vec![0, 2, 1], vec![5, 4, 3]];
x.iter_mut().map(foo)
}
fn main() {
bar();
}

View File

@ -0,0 +1,11 @@
error[E0271]: expected `foo` to be a fn item that returns `i32`, but it returns `()`
--> $DIR/issue-106991.rs:5:13
|
LL | fn bar() -> impl Iterator<Item = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `i32`
|
= note: required for `Map<std::slice::IterMut<'_, Vec<u8>>, for<'a> fn(&'a mut Vec<u8>) {foo}>` to implement `Iterator`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`.