From 99344a8b3231925bc52190b7e9c18a597c54ca90 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Mon, 20 Feb 2023 15:43:55 +0300 Subject: [PATCH] Add ui test for `E0271` error --- tests/ui/lint/issue-106991.rs | 13 +++++++++++++ tests/ui/lint/issue-106991.stderr | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/ui/lint/issue-106991.rs create mode 100644 tests/ui/lint/issue-106991.stderr diff --git a/tests/ui/lint/issue-106991.rs b/tests/ui/lint/issue-106991.rs new file mode 100644 index 0000000000000..e4d7f765b4a8a --- /dev/null +++ b/tests/ui/lint/issue-106991.rs @@ -0,0 +1,13 @@ +fn foo(items: &mut Vec) { + items.sort(); +} + +fn bar() -> impl Iterator { + //~^ ERROR expected `foo` to be a fn item that returns `i32`, but it returns `()` [E0271] + let mut x: Vec> = vec![vec![0, 2, 1], vec![5, 4, 3]]; + x.iter_mut().map(foo) +} + +fn main() { + bar(); +} diff --git a/tests/ui/lint/issue-106991.stderr b/tests/ui/lint/issue-106991.stderr new file mode 100644 index 0000000000000..7b43f0b2ca8f3 --- /dev/null +++ b/tests/ui/lint/issue-106991.stderr @@ -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 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `i32` + | + = note: required for `Map>, for<'a> fn(&'a mut Vec) {foo}>` to implement `Iterator` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`.