]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/unit_arg.rs
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / unit_arg.rs
index b6a7bc5a1cc95466bd3f3d4fa0c28a6998053753..07e70873a8132e4e3c07740d0e8000ee57dec249 100644 (file)
@@ -1,14 +1,21 @@
+// aux-build: proc_macro_with_span.rs
 #![warn(clippy::unit_arg)]
+#![allow(unused_must_use, unused_variables)]
 #![allow(
+    clippy::let_unit_value,
+    clippy::needless_question_mark,
+    clippy::never_loop,
     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,
+    clippy::uninlined_format_args,
+    clippy::unnecessary_wraps,
+    clippy::unused_unit
 )]
 
+extern crate proc_macro_with_span;
+
+use proc_macro_with_span::with_span;
 use std::fmt::Debug;
 
 fn foo<T: Debug>(t: T) {
@@ -27,6 +34,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;
@@ -59,7 +90,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() {
@@ -71,6 +102,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<(), ()> {
@@ -97,6 +132,10 @@ fn returning_expr() -> Option<()> {
 
 fn taking_multiple_units(a: (), b: ()) {}
 
+fn proc_macro() {
+    with_span!(span taking_multiple_units(unsafe { (); }, 'x: loop { break 'x (); }));
+}
+
 fn main() {
     bad();
     ok();