summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/map_collect_result_unit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/map_collect_result_unit.rs')
-rw-r--r--src/tools/clippy/tests/ui/map_collect_result_unit.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/map_collect_result_unit.rs b/src/tools/clippy/tests/ui/map_collect_result_unit.rs
new file mode 100644
index 000000000..6f08f4c3c
--- /dev/null
+++ b/src/tools/clippy/tests/ui/map_collect_result_unit.rs
@@ -0,0 +1,16 @@
+// run-rustfix
+#![warn(clippy::map_collect_result_unit)]
+
+fn main() {
+ {
+ let _ = (0..3).map(|t| Err(t + 1)).collect::<Result<(), _>>();
+ let _: Result<(), _> = (0..3).map(|t| Err(t + 1)).collect();
+
+ let _ = (0..3).try_for_each(|t| Err(t + 1));
+ }
+}
+
+fn _ignore() {
+ let _ = (0..3).map(|t| Err(t + 1)).collect::<Result<Vec<i32>, _>>();
+ let _ = (0..3).map(|t| Err(t + 1)).collect::<Vec<Result<(), _>>>();
+}