Skip to content

Commit

Permalink
Add ui test for E0271 error
Browse files Browse the repository at this point in the history
  • Loading branch information
obeis committed Feb 23, 2023
1 parent b93d545 commit 99344a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui/lint/issue-106991.rs
Original file line number Diff line number Diff line change
@@ -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();
}
11 changes: 11 additions & 0 deletions tests/ui/lint/issue-106991.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 99344a8

Please sign in to comment.