Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Sep 16, 2019
1 parent eaae523 commit 53fe3f9
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 51 deletions.
5 changes: 1 addition & 4 deletions clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ pub fn run(check: bool, verbose: bool) {
}

fn format_command(program: impl AsRef<OsStr>, dir: impl AsRef<Path>, args: &[impl AsRef<OsStr>]) -> String {
let arg_display: Vec<_> = args
.iter()
.map(|a| escape(a.as_ref().to_string_lossy()).to_owned())
.collect();
let arg_display: Vec<_> = args.iter().map(|a| escape(a.as_ref().to_string_lossy())).collect();

format!(
"cd {} && {} {}",
Expand Down
3 changes: 1 addition & 2 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {

let cfg_mode = mode.parse().expect("Invalid mode");
if let Ok(name) = var::<&str>("TESTNAME") {
let s: String = name.to_owned();
config.filter = Some(s)
config.filter = Some(name)
}

if rustc_test_suite().is_some() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/auxiliary/proc_macro_crash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn macro_test(input_stream: TokenStream) -> TokenStream {
TokenTree::Ident(Ident::new("true", Span::call_site())),
TokenTree::Group(clause.clone()),
TokenTree::Ident(Ident::new("else", Span::call_site())),
TokenTree::Group(clause.clone()),
TokenTree::Group(clause),
])
})),
])
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/escape_analysis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![feature(box_syntax)]
#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
#![allow(
clippy::borrowed_box,
clippy::needless_pass_by_value,
clippy::unused_unit,
clippy::redundant_clone
)]
#![warn(clippy::boxed_local)]

#[derive(Clone)]
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/escape_analysis.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: local variable doesn't need to be boxed here
--> $DIR/escape_analysis.rs:34:13
--> $DIR/escape_analysis.rs:39:13
|
LL | fn warn_arg(x: Box<A>) {
| ^
|
= note: `-D clippy::boxed-local` implied by `-D warnings`

error: local variable doesn't need to be boxed here
--> $DIR/escape_analysis.rs:125:12
--> $DIR/escape_analysis.rs:130:12
|
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^

error: local variable doesn't need to be boxed here
--> $DIR/escape_analysis.rs:165:23
--> $DIR/escape_analysis.rs:170:23
|
LL | fn closure_borrow(x: Box<A>) {
| ^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/map_clone.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-rustfix
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::iter_cloned_collect)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::clone_on_copy, clippy::redundant_clone)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::redundant_closure_for_method_calls)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/map_clone.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-rustfix
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::iter_cloned_collect)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::clone_on_copy, clippy::redundant_clone)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::redundant_closure_for_method_calls)]

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
clippy::single_match,
clippy::redundant_pattern_matching,
clippy::many_single_char_names,
clippy::option_option
clippy::option_option,
clippy::redundant_clone
)]

use std::borrow::Borrow;
Expand Down
52 changes: 26 additions & 26 deletions tests/ui/needless_pass_by_value.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:16:23
--> $DIR/needless_pass_by_value.rs:17:23
|
LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
| ^^^^^^ help: consider changing the type to: `&[T]`
|
= note: `-D clippy::needless-pass-by-value` implied by `-D warnings`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:30:11
--> $DIR/needless_pass_by_value.rs:31:11
|
LL | fn bar(x: String, y: Wrapper) {
| ^^^^^^ help: consider changing the type to: `&str`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:30:22
--> $DIR/needless_pass_by_value.rs:31:22
|
LL | fn bar(x: String, y: Wrapper) {
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:36:71
--> $DIR/needless_pass_by_value.rs:37:71
|
LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) {
| ^ help: consider taking a reference instead: `&V`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:48:18
--> $DIR/needless_pass_by_value.rs:49:18
|
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -36,13 +36,13 @@ LL | match *x {
|

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:61:24
--> $DIR/needless_pass_by_value.rs:62:24
|
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:61:36
--> $DIR/needless_pass_by_value.rs:62:36
|
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
| ^^^^^^^
Expand All @@ -55,19 +55,19 @@ LL | let Wrapper(_) = *y; // still not moved
|

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:77:49
--> $DIR/needless_pass_by_value.rs:78:49
|
LL | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {}
| ^ help: consider taking a reference instead: `&T`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:79:18
--> $DIR/needless_pass_by_value.rs:80:18
|
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
| ^^^^^^ help: consider taking a reference instead: `&String`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:79:29
--> $DIR/needless_pass_by_value.rs:80:29
|
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
| ^^^^^^
Expand All @@ -81,13 +81,13 @@ LL | let _ = t.to_string();
| ^^^^^^^^^^^^^

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:79:40
--> $DIR/needless_pass_by_value.rs:80:40
|
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
| ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:79:53
--> $DIR/needless_pass_by_value.rs:80:53
|
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
| ^^^^^^^^
Expand All @@ -101,61 +101,61 @@ LL | let _ = v.to_owned();
| ^^^^^^^^^^^^

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:92:12
--> $DIR/needless_pass_by_value.rs:93:12
|
LL | s: String,
| ^^^^^^ help: consider changing the type to: `&str`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:93:12
--> $DIR/needless_pass_by_value.rs:94:12
|
LL | t: String,
| ^^^^^^ help: consider taking a reference instead: `&String`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:102:23
--> $DIR/needless_pass_by_value.rs:103:23
|
LL | fn baz(&self, _u: U, _s: Self) {}
| ^ help: consider taking a reference instead: `&U`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:102:30
--> $DIR/needless_pass_by_value.rs:103:30
|
LL | fn baz(&self, _u: U, _s: Self) {}
| ^^^^ help: consider taking a reference instead: `&Self`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:124:24
--> $DIR/needless_pass_by_value.rs:125:24
|
LL | fn bar_copy(x: u32, y: CopyWrapper) {
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
help: consider marking this type as Copy
--> $DIR/needless_pass_by_value.rs:122:1
--> $DIR/needless_pass_by_value.rs:123:1
|
LL | struct CopyWrapper(u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:130:29
--> $DIR/needless_pass_by_value.rs:131:29
|
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
help: consider marking this type as Copy
--> $DIR/needless_pass_by_value.rs:122:1
--> $DIR/needless_pass_by_value.rs:123:1
|
LL | struct CopyWrapper(u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:130:45
--> $DIR/needless_pass_by_value.rs:131:45
|
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
| ^^^^^^^^^^^
|
help: consider marking this type as Copy
--> $DIR/needless_pass_by_value.rs:122:1
--> $DIR/needless_pass_by_value.rs:123:1
|
LL | struct CopyWrapper(u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -168,13 +168,13 @@ LL | let CopyWrapper(_) = *y; // still not moved
|

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:130:61
--> $DIR/needless_pass_by_value.rs:131:61
|
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
| ^^^^^^^^^^^
|
help: consider marking this type as Copy
--> $DIR/needless_pass_by_value.rs:122:1
--> $DIR/needless_pass_by_value.rs:123:1
|
LL | struct CopyWrapper(u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -185,13 +185,13 @@ LL | let CopyWrapper(s) = *z; // moved
|

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:142:40
--> $DIR/needless_pass_by_value.rs:143:40
|
LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
| ^ help: consider taking a reference instead: `&S`

error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:147:20
--> $DIR/needless_pass_by_value.rs:148:20
|
LL | fn more_fun(_item: impl Club<'static, i32>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/ptr_arg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused, clippy::many_single_char_names)]
#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
#![warn(clippy::ptr_arg)]

use std::borrow::Cow;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/question_mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn main() {
};
move_struct.ref_func();
move_struct.clone().mov_func_reuse();
move_struct.clone().mov_func_no_use();
move_struct.mov_func_no_use();

let so = SeemsOption::Some(45);
returns_something_similar_to_option(so);
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/swap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#![warn(clippy::all)]
#![allow(clippy::blacklisted_name, clippy::no_effect, redundant_semicolon, unused_assignments)]
#![allow(
clippy::blacklisted_name,
clippy::no_effect,
clippy::redundant_clone,
redundant_semicolon,
unused_assignments
)]

struct Foo(u32);

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/swap.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: this looks like you are swapping elements of `foo` manually
--> $DIR/swap.rs:27:5
--> $DIR/swap.rs:33:5
|
LL | / let temp = foo[0];
LL | | foo[0] = foo[1];
Expand All @@ -9,23 +9,23 @@ LL | | foo[1] = temp;
= note: `-D clippy::manual-swap` implied by `-D warnings`

error: this looks like you are swapping elements of `foo` manually
--> $DIR/swap.rs:36:5
--> $DIR/swap.rs:42:5
|
LL | / let temp = foo[0];
LL | | foo[0] = foo[1];
LL | | foo[1] = temp;
| |_________________^ help: try: `foo.swap(0, 1)`

error: this looks like you are swapping elements of `foo` manually
--> $DIR/swap.rs:45:5
--> $DIR/swap.rs:51:5
|
LL | / let temp = foo[0];
LL | | foo[0] = foo[1];
LL | | foo[1] = temp;
| |_________________^ help: try: `foo.swap(0, 1)`

error: this looks like you are swapping `a` and `b` manually
--> $DIR/swap.rs:65:7
--> $DIR/swap.rs:71:7
|
LL | ; let t = a;
| _______^
Expand All @@ -36,7 +36,7 @@ LL | | b = t;
= note: or maybe you should use `std::mem::replace`?

error: this looks like you are swapping `c.0` and `a` manually
--> $DIR/swap.rs:74:7
--> $DIR/swap.rs:80:7
|
LL | ; let t = c.0;
| _______^
Expand All @@ -47,7 +47,7 @@ LL | | a = t;
= note: or maybe you should use `std::mem::replace`?

error: this looks like you are trying to swap `a` and `b`
--> $DIR/swap.rs:62:5
--> $DIR/swap.rs:68:5
|
LL | / a = b;
LL | | b = a;
Expand All @@ -57,7 +57,7 @@ LL | | b = a;
= note: or maybe you should use `std::mem::replace`?

error: this looks like you are trying to swap `c.0` and `a`
--> $DIR/swap.rs:71:5
--> $DIR/swap.rs:77:5
|
LL | / c.0 = a;
LL | | a = c.0;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unnecessary_clone.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::clone_on_ref_ptr)]
#![allow(unused)]
#![allow(unused, clippy::redundant_clone)]

use std::cell::RefCell;
use std::collections::HashSet;
Expand Down

0 comments on commit 53fe3f9

Please sign in to comment.