Skip to content

Commit

Permalink
fallout: allow new uninlined_format_args in tests
Browse files Browse the repository at this point in the history
in order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

* minor spelling rename - "moveable" -> "movable"
  • Loading branch information
nyurik committed Oct 1, 2022
1 parent 68408c5 commit 6d7a773
Show file tree
Hide file tree
Showing 185 changed files with 1,045 additions and 1,012 deletions.
2 changes: 2 additions & 0 deletions tests/ui-toml/conf_deprecated_key/conf_deprecated_key.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::uninlined_format_args)]

fn main() {}

#[warn(clippy::cognitive_complexity)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecate
warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecated field `blacklisted-names`. Please use `disallowed-names` instead

error: the function has a cognitive complexity of (3/2)
--> $DIR/conf_deprecated_key.rs:4:4
--> $DIR/conf_deprecated_key.rs:6:4
|
LL | fn cognitive_complexity() {
| ^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 3 additions & 2 deletions tests/ui/assertions_on_result_states.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::uninlined_format_args)]

use std::result::Result;

Expand Down Expand Up @@ -46,10 +47,10 @@ fn main() {

// test ok that shouldn't be moved
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
fn test_ref_unmoveable_ok(r: &Result<CopyFoo, DebugFoo>) {
fn test_ref_unmovable_ok(r: &Result<CopyFoo, DebugFoo>) {
assert!(r.is_ok());
}
test_ref_unmoveable_ok(&r);
test_ref_unmovable_ok(&r);
assert!(r.is_ok());
r.unwrap();

Expand Down
5 changes: 3 additions & 2 deletions tests/ui/assertions_on_result_states.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::uninlined_format_args)]

use std::result::Result;

Expand Down Expand Up @@ -46,10 +47,10 @@ fn main() {

// test ok that shouldn't be moved
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
fn test_ref_unmoveable_ok(r: &Result<CopyFoo, DebugFoo>) {
fn test_ref_unmovable_ok(r: &Result<CopyFoo, DebugFoo>) {
assert!(r.is_ok());
}
test_ref_unmoveable_ok(&r);
test_ref_unmovable_ok(&r);
assert!(r.is_ok());
r.unwrap();

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/assertions_on_result_states.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:24:5
--> $DIR/assertions_on_result_states.rs:25:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
|
= note: `-D clippy::assertions-on-result-states` implied by `-D warnings`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:42:5
--> $DIR/assertions_on_result_states.rs:43:5
|
LL | assert!(get_ok().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:45:5
--> $DIR/assertions_on_result_states.rs:46:5
|
LL | assert!(get_ok_macro!().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:58:5
--> $DIR/assertions_on_result_states.rs:59:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:64:9
--> $DIR/assertions_on_result_states.rs:65:9
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:72:5
--> $DIR/assertions_on_result_states.rs:73:5
|
LL | assert!(r.is_err());
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`

error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:82:5
--> $DIR/assertions_on_result_states.rs:83:5
|
LL | assert!(res.is_err())
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/assign_ops2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::uninlined_format_args)]

#[allow(unused_assignments)]
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/assign_ops2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:5:5
--> $DIR/assign_ops2.rs:7:5
|
LL | a += a + 1;
| ^^^^^^^^^^
Expand All @@ -15,7 +15,7 @@ LL | a = a + a + 1;
| ~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:6:5
--> $DIR/assign_ops2.rs:8:5
|
LL | a += 1 + a;
| ^^^^^^^^^^
Expand All @@ -30,7 +30,7 @@ LL | a = a + 1 + a;
| ~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:7:5
--> $DIR/assign_ops2.rs:9:5
|
LL | a -= a - 1;
| ^^^^^^^^^^
Expand All @@ -45,7 +45,7 @@ LL | a = a - (a - 1);
| ~~~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:8:5
--> $DIR/assign_ops2.rs:10:5
|
LL | a *= a * 99;
| ^^^^^^^^^^^
Expand All @@ -60,7 +60,7 @@ LL | a = a * a * 99;
| ~~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:9:5
--> $DIR/assign_ops2.rs:11:5
|
LL | a *= 42 * a;
| ^^^^^^^^^^^
Expand All @@ -75,7 +75,7 @@ LL | a = a * 42 * a;
| ~~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:10:5
--> $DIR/assign_ops2.rs:12:5
|
LL | a /= a / 2;
| ^^^^^^^^^^
Expand All @@ -90,7 +90,7 @@ LL | a = a / (a / 2);
| ~~~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:11:5
--> $DIR/assign_ops2.rs:13:5
|
LL | a %= a % 5;
| ^^^^^^^^^^
Expand All @@ -105,7 +105,7 @@ LL | a = a % (a % 5);
| ~~~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:12:5
--> $DIR/assign_ops2.rs:14:5
|
LL | a &= a & 1;
| ^^^^^^^^^^
Expand All @@ -120,7 +120,7 @@ LL | a = a & a & 1;
| ~~~~~~~~~~~~~

error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:13:5
--> $DIR/assign_ops2.rs:15:5
|
LL | a *= a * a;
| ^^^^^^^^^^
Expand All @@ -135,7 +135,7 @@ LL | a = a * a * a;
| ~~~~~~~~~~~~~

error: manual implementation of an assign operation
--> $DIR/assign_ops2.rs:50:5
--> $DIR/assign_ops2.rs:52:5
|
LL | buf = buf + cows.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/auxiliary/proc_macro_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![crate_type = "proc-macro"]
#![feature(repr128, proc_macro_hygiene, proc_macro_quote, box_patterns)]
#![allow(incomplete_features)]
#![allow(clippy::useless_conversion)]
#![allow(clippy::useless_conversion, clippy::uninlined_format_args)]

extern crate proc_macro;
extern crate quote;
Expand Down
1 change: 1 addition & 0 deletions tests/ui/bind_instead_of_map.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::uninlined_format_args)]

// need a main anyway, use it get rid of unused warnings too
pub fn main() {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/bind_instead_of_map.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::uninlined_format_args)]

// need a main anyway, use it get rid of unused warnings too
pub fn main() {
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/bind_instead_of_map.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: using `Option.and_then(Some)`, which is a no-op
--> $DIR/bind_instead_of_map.rs:8:13
--> $DIR/bind_instead_of_map.rs:9:13
|
LL | let _ = x.and_then(Some);
| ^^^^^^^^^^^^^^^^ help: use the expression directly: `x`
Expand All @@ -11,13 +11,13 @@ LL | #![deny(clippy::bind_instead_of_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map.rs:9:13
--> $DIR/bind_instead_of_map.rs:10:13
|
LL | let _ = x.and_then(|o| Some(o + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.map(|o| o + 1)`

error: using `Result.and_then(Ok)`, which is a no-op
--> $DIR/bind_instead_of_map.rs:15:13
--> $DIR/bind_instead_of_map.rs:16:13
|
LL | let _ = x.and_then(Ok);
| ^^^^^^^^^^^^^^ help: use the expression directly: `x`
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/borrow_box.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![deny(clippy::borrowed_box)]
#![allow(clippy::disallowed_names)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(dead_code, unused_variables)]
#![allow(clippy::uninlined_format_args, clippy::disallowed_names)]

use std::fmt::Display;

Expand Down
20 changes: 10 additions & 10 deletions tests/ui/borrow_box.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:21:14
--> $DIR/borrow_box.rs:20:14
|
LL | let foo: &Box<bool>;
| ^^^^^^^^^^ help: try: `&bool`
Expand All @@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
| ^^^^^^^^^^^^^^^^^^^^

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:25:10
--> $DIR/borrow_box.rs:24:10
|
LL | foo: &'a Box<bool>,
| ^^^^^^^^^^^^^ help: try: `&'a bool`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:29:17
--> $DIR/borrow_box.rs:28:17
|
LL | fn test4(a: &Box<bool>);
| ^^^^^^^^^^ help: try: `&bool`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:95:25
--> $DIR/borrow_box.rs:94:25
|
LL | pub fn test14(_display: &Box<dyn Display>) {}
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:96:25
--> $DIR/borrow_box.rs:95:25
|
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:97:29
--> $DIR/borrow_box.rs:96:29
|
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:99:25
--> $DIR/borrow_box.rs:98:25
|
LL | pub fn test17(_display: &Box<impl Display>) {}
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:100:25
--> $DIR/borrow_box.rs:99:25
|
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:101:29
--> $DIR/borrow_box.rs:100:29
|
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`

error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:106:25
--> $DIR/borrow_box.rs:105:25
|
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
Expand Down
17 changes: 9 additions & 8 deletions tests/ui/branches_sharing_code/shared_at_bottom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(dead_code, clippy::equatable_if_let)]
#![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
#![allow(dead_code)]
#![allow(clippy::equatable_if_let, clippy::uninlined_format_args)]

// This tests the branches_sharing_code lint at the end of blocks

Expand All @@ -11,10 +12,10 @@ fn simple_examples() {
let start_value = 0;
println!("=^.^=");

// Same but not moveable due to `start_value`
// Same but not movable due to `start_value`
let _ = start_value;

// The rest is self contained and moveable => Only lint the rest
// The rest is self contained and movable => Only lint the rest
let result = false;
println!("Block end!");
result
Expand All @@ -23,10 +24,10 @@ fn simple_examples() {
let start_value = 8;
println!("xD");

// Same but not moveable due to `start_value`
// Same but not movable due to `start_value`
let _ = start_value;

// The rest is self contained and moveable => Only lint the rest
// The rest is self contained and movable => Only lint the rest
let result = false;
println!("Block end!");
result
Expand Down Expand Up @@ -55,15 +56,15 @@ fn simple_examples() {
println!("I'm a local because I use the value `z`: `{}`", z);

println!(
"I'm moveable because I know: `outer_scope_value`: '{}'",
"I'm movable because I know: `outer_scope_value`: '{}'",
outer_scope_value
);
} else {
let z = 45678000;
println!("I'm a local because I use the value `z`: `{}`", z);

println!(
"I'm moveable because I know: `outer_scope_value`: '{}'",
"I'm movable because I know: `outer_scope_value`: '{}'",
outer_scope_value
);
}
Expand Down Expand Up @@ -110,7 +111,7 @@ fn simple_but_suggestion_is_invalid() {
}

/// Tests where the blocks are not linted due to the used value scope
fn not_moveable_due_to_value_scope() {
fn not_movable_due_to_value_scope() {
let x = 18;

// Using a local value in the moved code
Expand Down
Loading

0 comments on commit 6d7a773

Please sign in to comment.