#![warn(clippy::unit_arg)] #![allow(unused_must_use, unused_variables)] #![allow(clippy::no_effect, clippy::uninlined_format_args)] use std::fmt::Debug; fn foo(t: T) { println!("{:?}", t); } fn foo3(t1: T1, t2: T2, t3: T3) { println!("{:?}, {:?}, {:?}", t1, t2, t3); } fn bad() { foo(()); //~^ unit_arg foo3((), 2, 2); //~^ unit_arg foo(0); taking_two_units((), ()); //~^ unit_arg foo(0); foo(1); taking_three_units((), (), ()); //~^ unit_arg } fn taking_two_units(a: (), b: ()) {} fn taking_three_units(a: (), b: (), c: ()) {} fn main() { bad(); } fn issue14857() { let fn_take_unit = |_: ()| {}; fn_take_unit(()); //~^ unit_arg fn some_other_fn(_: &i32) {} macro_rules! another_mac { () => { some_other_fn(&Default::default()) }; ($e:expr) => { some_other_fn(&$e) }; } another_mac!(); fn_take_unit(()); //~^ unit_arg another_mac!(1); fn_take_unit(()); //~^ unit_arg macro_rules! mac { (nondef $e:expr) => { $e }; (empty_block) => {{}}; } fn_take_unit(mac!(nondef ())); //~^ unit_arg mac!(empty_block); fn_take_unit(()); //~^ unit_arg fn def() -> T { Default::default() } let _: () = def(); fn_take_unit(()); //~^ unit_arg }