]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/unit_arg.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / unit_arg.rs
index 2e2bd054e42aa027231c3f9ebe8a376f214079c1..535683729f686a965f7aab4618adae726a9c6aee 100644 (file)
@@ -1,5 +1,14 @@
 #![warn(clippy::unit_arg)]
-#![allow(clippy::no_effect, unused_must_use, unused_variables, clippy::unused_unit)]
+#![allow(
+    clippy::no_effect,
+    unused_must_use,
+    unused_variables,
+    clippy::unused_unit,
+    clippy::unnecessary_wraps,
+    clippy::or_fun_call,
+    clippy::needless_question_mark,
+    clippy::self_named_constructors
+)]
 
 use std::fmt::Debug;
 
@@ -19,6 +28,30 @@ fn bar<T: Debug>(&self, t: T) {
     }
 }
 
+fn baz<T: Debug>(t: T) {
+    foo(t);
+}
+
+trait Tr {
+    type Args;
+    fn do_it(args: Self::Args);
+}
+
+struct A;
+impl Tr for A {
+    type Args = ();
+    fn do_it(_: Self::Args) {}
+}
+
+struct B;
+impl Tr for B {
+    type Args = <A as Tr>::Args;
+
+    fn do_it(args: Self::Args) {
+        A::do_it(args)
+    }
+}
+
 fn bad() {
     foo({
         1;
@@ -51,7 +84,7 @@ fn bad() {
     None.or(Some(foo(2)));
     // in this case, the suggestion can be inlined, no need for a surrounding block
     // foo(()); foo(()) instead of { foo(()); foo(()) }
-    foo(foo(()))
+    foo(foo(()));
 }
 
 fn ok() {
@@ -63,6 +96,10 @@ fn ok() {
     b.bar({ 1 });
     b.bar(());
     question_mark();
+    let named_unit_arg = ();
+    foo(named_unit_arg);
+    baz(());
+    B::do_it(());
 }
 
 fn question_mark() -> Result<(), ()> {