]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/result_map_unit_fn_fixable.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / result_map_unit_fn_fixable.rs
index a8e891d8db024636560b72709bd72ad24569efc3..44f50d21109cddefefd4cd41f12dab76dd965f74 100644 (file)
@@ -1,6 +1,7 @@
-#![feature(never_type)]
+// run-rustfix
 #![warn(clippy::result_map_unit_fn)]
 #![allow(unused)]
+#![allow(clippy::uninlined_format_args)]
 
 fn do_nothing<T>(_: T) {}
 
@@ -17,9 +18,9 @@ struct HasResult {
 }
 
 impl HasResult {
-    fn do_result_nothing(self: &Self, value: usize) {}
+    fn do_result_nothing(&self, value: usize) {}
 
-    fn do_result_plus_one(self: &Self, value: usize) -> usize {
+    fn do_result_plus_one(&self, value: usize) -> usize {
         value + 1
     }
 }
@@ -75,28 +76,7 @@ fn result_map_unit_fn() {
 
     x.field.map(|ref value| { do_nothing(value + captured) });
 
-
-    x.field.map(|value| { do_nothing(value); do_nothing(value) });
-
-    x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
-
-    // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
-    // proper suggestion for these cases
-    x.field.map(|value| {
-        do_nothing(value);
-        do_nothing(value)
-    });
-    x.field.map(|value| { do_nothing(value); do_nothing(value); });
-
-    // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them
-    let res: Result<!, usize> = Ok(42).map(diverge);
-    "12".parse::<i32>().map(diverge);
-
-    let res: Result<(), usize> = Ok(plus_one(1)).map(do_nothing);
-
-    // Should suggest `if let Ok(_y) ...` to not override the existing foo variable
-    let y: Result<usize, usize> = Ok(42);
-    y.map(do_nothing);
+    x.field.map(|value| println!("{:?}", value));
 }
 
 fn main() {}