Skip to content

Commit 99344a8

Browse files
committed
Add ui test for E0271 error
1 parent b93d545 commit 99344a8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/ui/lint/issue-106991.rs

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

tests/ui/lint/issue-106991.stderr

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

0 commit comments

Comments
 (0)