mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add ui test for E0271
error
This commit is contained in:
parent
b93d54556f
commit
99344a8b32
13
tests/ui/lint/issue-106991.rs
Normal file
13
tests/ui/lint/issue-106991.rs
Normal 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();
|
||||
}
|
11
tests/ui/lint/issue-106991.stderr
Normal file
11
tests/ui/lint/issue-106991.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user