Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#![warn(clippy::unit_arg)] | ||
#![allow(clippy::no_effect, unused_must_use, unused_variables)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn foo<T: Debug>(t: T) { | ||
println!("{:?}", t); | ||
} | ||
|
||
fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) { | ||
println!("{:?}, {:?}, {:?}", t1, t2, t3); | ||
} | ||
|
||
fn bad() { | ||
foo({}); | ||
foo3({}, 2, 2); | ||
taking_two_units({}, foo(0)); | ||
taking_three_units({}, foo(0), foo(1)); | ||
} | ||
|
||
fn taking_two_units(a: (), b: ()) {} | ||
fn taking_three_units(a: (), b: (), c: ()) {} | ||
|
||
fn main() { | ||
bad(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
error: passing a unit value to a function | ||
--> $DIR/unit_arg_empty_blocks.rs:15:5 | ||
| | ||
LL | foo({}); | ||
| ^^^^--^ | ||
| | | ||
| help: use a unit literal instead: `()` | ||
| | ||
= note: `-D clippy::unit-arg` implied by `-D warnings` | ||
|
||
error: passing a unit value to a function | ||
--> $DIR/unit_arg_empty_blocks.rs:16:5 | ||
| | ||
LL | foo3({}, 2, 2); | ||
| ^^^^^--^^^^^^^ | ||
| | | ||
| help: use a unit literal instead: `()` | ||
|
||
error: passing unit values to a function | ||
--> $DIR/unit_arg_empty_blocks.rs:17:5 | ||
| | ||
LL | taking_two_units({}, foo(0)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: move the expression in front of the call... | ||
| | ||
LL | foo(0); | ||
| | ||
help: ...and use unit literals instead | ||
| | ||
LL | taking_two_units((), ()); | ||
| ^^ ^^ | ||
|
||
error: passing unit values to a function | ||
--> $DIR/unit_arg_empty_blocks.rs:18:5 | ||
| | ||
LL | taking_three_units({}, foo(0), foo(1)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: move the expressions in front of the call... | ||
| | ||
LL | foo(0); | ||
LL | foo(1); | ||
| | ||
help: ...and use unit literals instead | ||
| | ||
LL | taking_three_units((), (), ()); | ||
| ^^ ^^ ^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|