mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
Update test files
This commit is contained in:
parent
4c9cefa122
commit
6d15a14964
@ -1,79 +0,0 @@
|
||||
// run-rustfix
|
||||
#![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);
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Bar {
|
||||
fn bar<T: Debug>(&self, t: T) {
|
||||
println!("{:?}", t);
|
||||
}
|
||||
}
|
||||
|
||||
fn bad() {
|
||||
{}; foo(());
|
||||
{
|
||||
1;
|
||||
}; foo(());
|
||||
foo(1); foo(());
|
||||
{
|
||||
foo(1);
|
||||
foo(2);
|
||||
}; foo(());
|
||||
{}; foo3((), 2, 2);
|
||||
let b = Bar;
|
||||
{
|
||||
1;
|
||||
}; b.bar(());
|
||||
foo(0); foo(1); taking_multiple_units((), ());
|
||||
}
|
||||
|
||||
fn ok() {
|
||||
foo(());
|
||||
foo(1);
|
||||
foo({ 1 });
|
||||
foo3("a", 3, vec![3]);
|
||||
let b = Bar;
|
||||
b.bar({ 1 });
|
||||
b.bar(());
|
||||
question_mark();
|
||||
}
|
||||
|
||||
fn question_mark() -> Result<(), ()> {
|
||||
Ok(Ok(())?)?;
|
||||
Ok(Ok(()))??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_2945 {
|
||||
fn unit_fn() -> Result<(), i32> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fallible() -> Result<(), i32> {
|
||||
Ok(unit_fn()?)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn returning_expr() -> Option<()> {
|
||||
foo(1); Some(())
|
||||
}
|
||||
|
||||
fn taking_multiple_units(a: (), b: ()) {}
|
||||
|
||||
fn main() {
|
||||
bad();
|
||||
ok();
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
// run-rustfix
|
||||
#![warn(clippy::unit_arg)]
|
||||
#![allow(clippy::no_effect, unused_must_use, unused_variables)]
|
||||
|
||||
@ -36,6 +35,20 @@ fn bad() {
|
||||
1;
|
||||
});
|
||||
taking_multiple_units(foo(0), foo(1));
|
||||
taking_multiple_units(foo(0), {
|
||||
foo(1);
|
||||
foo(2);
|
||||
});
|
||||
taking_multiple_units(
|
||||
{
|
||||
foo(0);
|
||||
foo(1);
|
||||
},
|
||||
{
|
||||
foo(2);
|
||||
foo(3);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn ok() {
|
||||
|
@ -1,34 +1,53 @@
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:24:5
|
||||
--> $DIR/unit_arg.rs:23:5
|
||||
|
|
||||
LL | foo({});
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::unit-arg` implied by `-D warnings`
|
||||
help: move the expressions in front of the call...
|
||||
help: move the expression in front of the call...
|
||||
|
|
||||
LL | {}; foo({});
|
||||
| ^^^
|
||||
help: ...and use unit literals instead
|
||||
LL | {};
|
||||
|
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:25:5
|
||||
--> $DIR/unit_arg.rs:24:5
|
||||
|
|
||||
LL | / foo({
|
||||
LL | | 1;
|
||||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | 1
|
||||
|
|
||||
help: or move the expression in front of the call...
|
||||
|
|
||||
LL | {
|
||||
LL | 1;
|
||||
LL | }; foo({
|
||||
LL | };
|
||||
|
|
||||
help: ...and use unit literals instead
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:27:5
|
||||
|
|
||||
LL | foo(foo(1));
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: move the expression in front of the call...
|
||||
|
|
||||
LL | foo(1);
|
||||
|
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^
|
||||
@ -36,106 +55,157 @@ LL | foo(());
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:28:5
|
||||
|
|
||||
LL | foo(foo(1));
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
|
|
||||
LL | foo(1); foo(foo(1));
|
||||
| ^^^^^^^
|
||||
help: ...and use unit literals instead
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:29:5
|
||||
|
|
||||
LL | / foo({
|
||||
LL | | foo(1);
|
||||
LL | | foo(2);
|
||||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | foo(2)
|
||||
|
|
||||
help: or move the expression in front of the call...
|
||||
|
|
||||
LL | {
|
||||
LL | foo(1);
|
||||
LL | foo(2);
|
||||
LL | }; foo({
|
||||
LL | };
|
||||
|
|
||||
help: ...and use unit literals instead
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:33:5
|
||||
--> $DIR/unit_arg.rs:32:5
|
||||
|
|
||||
LL | foo3({}, 2, 2);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
help: move the expression in front of the call...
|
||||
|
|
||||
LL | {}; foo3({}, 2, 2);
|
||||
| ^^^
|
||||
help: ...and use unit literals instead
|
||||
LL | {};
|
||||
|
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | foo3((), 2, 2);
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:35:5
|
||||
--> $DIR/unit_arg.rs:34:5
|
||||
|
|
||||
LL | / b.bar({
|
||||
LL | | 1;
|
||||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | 1
|
||||
|
|
||||
help: or move the expression in front of the call...
|
||||
|
|
||||
LL | {
|
||||
LL | 1;
|
||||
LL | }; b.bar({
|
||||
LL | };
|
||||
|
|
||||
help: ...and use unit literals instead
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | b.bar(());
|
||||
| ^^
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:38:5
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:37:5
|
||||
|
|
||||
LL | taking_multiple_units(foo(0), foo(1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
|
|
||||
LL | foo(0); foo(1); taking_multiple_units(foo(0), foo(1));
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | foo(0);
|
||||
LL | foo(1);
|
||||
|
|
||||
help: ...and use unit literals instead
|
||||
|
|
||||
LL | taking_multiple_units((), foo(1));
|
||||
| ^^
|
||||
LL | taking_multiple_units((), ());
|
||||
| ^^ ^^
|
||||
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:38:5
|
||||
|
|
||||
LL | / taking_multiple_units(foo(0), {
|
||||
LL | | foo(1);
|
||||
LL | | foo(2);
|
||||
LL | | });
|
||||
| |______^
|
||||
|
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | foo(2)
|
||||
|
|
||||
help: or move the expressions in front of the call...
|
||||
|
|
||||
LL | foo(0);
|
||||
LL | {
|
||||
LL | foo(1);
|
||||
LL | foo(2);
|
||||
LL | };
|
||||
|
|
||||
help: ...and use unit literals instead
|
||||
|
|
||||
LL | taking_multiple_units(foo(0), ());
|
||||
| ^^
|
||||
LL | taking_multiple_units((), ());
|
||||
| ^^ ^^
|
||||
|
||||
error: passing unit values to a function
|
||||
--> $DIR/unit_arg.rs:42:5
|
||||
|
|
||||
LL | / taking_multiple_units(
|
||||
LL | | {
|
||||
LL | | foo(0);
|
||||
LL | | foo(1);
|
||||
... |
|
||||
LL | | },
|
||||
LL | | );
|
||||
| |_____^
|
||||
|
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | foo(1)
|
||||
|
|
||||
help: remove the semicolon from the last statement in the block
|
||||
|
|
||||
LL | foo(3)
|
||||
|
|
||||
help: or move the expressions in front of the call...
|
||||
|
|
||||
LL | {
|
||||
LL | foo(0);
|
||||
LL | foo(1);
|
||||
LL | };
|
||||
LL | {
|
||||
LL | foo(2);
|
||||
...
|
||||
help: ...and use unit literals instead
|
||||
|
|
||||
LL | (),
|
||||
LL | (),
|
||||
|
|
||||
|
||||
error: passing a unit value to a function
|
||||
--> $DIR/unit_arg.rs:71:5
|
||||
--> $DIR/unit_arg.rs:84:5
|
||||
|
|
||||
LL | Some(foo(1))
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
help: move the expressions in front of the call...
|
||||
help: move the expression in front of the call...
|
||||
|
|
||||
LL | foo(1); Some(foo(1))
|
||||
| ^^^^^^^
|
||||
help: ...and use unit literals instead
|
||||
LL | foo(1);
|
||||
|
|
||||
help: ...and use a unit literal instead
|
||||
|
|
||||
LL | Some(())
|
||||
| ^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user