Skip to content

Commit

Permalink
restore tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lengyijun committed Sep 10, 2021
1 parent d7784d3 commit c81cd9a
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 46 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/same_name_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
then{
// FIXME: if
// `rustc_middle::ty::assoc::AssocItems::items` is public,
// we can iterate its keys, which's more efficient
// we can iterate its keys instead of `in_definition_order`,
// which's more efficient
cx.tcx
.associated_items(did)
.in_definition_order()
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/clone_on_copy.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
clippy::no_effect,
clippy::unnecessary_operation,
clippy::vec_init_then_push,
clippy::toplevel_ref_arg,
clippy::same_name_method
clippy::toplevel_ref_arg
)]

use std::cell::RefCell;
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/clone_on_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
clippy::no_effect,
clippy::unnecessary_operation,
clippy::vec_init_then_push,
clippy::toplevel_ref_arg,
clippy::same_name_method
clippy::toplevel_ref_arg
)]

use std::cell::RefCell;
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/clone_on_copy.stderr
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:25:5
--> $DIR/clone_on_copy.rs:24:5
|
LL | 42.clone();
| ^^^^^^^^^^ help: try removing the `clone` call: `42`
|
= note: `-D clippy::clone-on-copy` implied by `-D warnings`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:29:5
--> $DIR/clone_on_copy.rs:28:5
|
LL | (&42).clone();
| ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:32:5
--> $DIR/clone_on_copy.rs:31:5
|
LL | rc.borrow().clone();
| ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()`

error: using `clone` on type `u32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:35:5
--> $DIR/clone_on_copy.rs:34:5
|
LL | x.clone().rotate_left(1);
| ^^^^^^^^^ help: try removing the `clone` call: `x`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:49:5
--> $DIR/clone_on_copy.rs:48:5
|
LL | m!(42).clone();
| ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)`

error: using `clone` on type `[u32; 2]` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:59:5
--> $DIR/clone_on_copy.rs:58:5
|
LL | x.clone()[0];
| ^^^^^^^^^ help: try dereferencing it: `(*x)`

error: using `clone` on type `char` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:69:14
--> $DIR/clone_on_copy.rs:68:14
|
LL | is_ascii('z'.clone());
| ^^^^^^^^^^^ help: try removing the `clone` call: `'z'`

error: using `clone` on type `i32` which implements the `Copy` trait
--> $DIR/clone_on_copy.rs:73:14
--> $DIR/clone_on_copy.rs:72:14
|
LL | vec.push(42.clone());
| ^^^^^^^^^^ help: try removing the `clone` call: `42`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/len_without_is_empty.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// edition:2018

#![warn(clippy::len_without_is_empty)]
#![allow(dead_code, unused, clippy::same_name_method)]
#![allow(dead_code, unused)]

pub struct PubOne;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/or_fun_call.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![warn(clippy::or_fun_call)]
#![allow(dead_code)]
#![allow(clippy::unnecessary_wraps)]
#![allow(clippy::same_name_method)]

use std::collections::BTreeMap;
use std::collections::HashMap;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/or_fun_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![warn(clippy::or_fun_call)]
#![allow(dead_code)]
#![allow(clippy::unnecessary_wraps)]
#![allow(clippy::same_name_method)]

use std::collections::BTreeMap;
use std::collections::HashMap;
Expand Down
48 changes: 24 additions & 24 deletions tests/ui/or_fun_call.stderr
Original file line number Diff line number Diff line change
@@ -1,145 +1,145 @@
error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:47:19
--> $DIR/or_fun_call.rs:46:19
|
LL | with_const_fn.unwrap_or(Duration::from_secs(5));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Duration::from_secs(5))`
|
= note: `-D clippy::or-fun-call` implied by `-D warnings`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:50:22
--> $DIR/or_fun_call.rs:49:22
|
LL | with_constructor.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`

error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:53:5
--> $DIR/or_fun_call.rs:52:5
|
LL | with_new.unwrap_or(Vec::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:56:21
--> $DIR/or_fun_call.rs:55:21
|
LL | with_const_args.unwrap_or(Vec::with_capacity(12));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:59:14
--> $DIR/or_fun_call.rs:58:14
|
LL | with_err.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:62:19
--> $DIR/or_fun_call.rs:61:19
|
LL | with_err_args.unwrap_or(Vec::with_capacity(12));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`

error: use of `unwrap_or` followed by a call to `default`
--> $DIR/or_fun_call.rs:65:5
--> $DIR/or_fun_call.rs:64:5
|
LL | with_default_trait.unwrap_or(Default::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`

error: use of `unwrap_or` followed by a call to `default`
--> $DIR/or_fun_call.rs:68:5
--> $DIR/or_fun_call.rs:67:5
|
LL | with_default_type.unwrap_or(u64::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:71:18
--> $DIR/or_fun_call.rs:70:18
|
LL | self_default.unwrap_or(<FakeDefault>::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(<FakeDefault>::default)`

error: use of `unwrap_or` followed by a call to `default`
--> $DIR/or_fun_call.rs:74:5
--> $DIR/or_fun_call.rs:73:5
|
LL | real_default.unwrap_or(<FakeDefault as Default>::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `real_default.unwrap_or_default()`

error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:77:5
--> $DIR/or_fun_call.rs:76:5
|
LL | with_vec.unwrap_or(vec![]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_vec.unwrap_or_default()`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:80:21
--> $DIR/or_fun_call.rs:79:21
|
LL | without_default.unwrap_or(Foo::new());
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`

error: use of `or_insert` followed by a function call
--> $DIR/or_fun_call.rs:83:19
--> $DIR/or_fun_call.rs:82:19
|
LL | map.entry(42).or_insert(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`

error: use of `or_insert` followed by a function call
--> $DIR/or_fun_call.rs:86:23
--> $DIR/or_fun_call.rs:85:23
|
LL | map_vec.entry(42).or_insert(vec![]);
| ^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(Vec::new)`

error: use of `or_insert` followed by a function call
--> $DIR/or_fun_call.rs:89:21
--> $DIR/or_fun_call.rs:88:21
|
LL | btree.entry(42).or_insert(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`

error: use of `or_insert` followed by a function call
--> $DIR/or_fun_call.rs:92:25
--> $DIR/or_fun_call.rs:91:25
|
LL | btree_vec.entry(42).or_insert(vec![]);
| ^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(Vec::new)`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:95:21
--> $DIR/or_fun_call.rs:94:21
|
LL | let _ = stringy.unwrap_or("".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:103:21
--> $DIR/or_fun_call.rs:102:21
|
LL | let _ = Some(1).unwrap_or(map[&1]);
| ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:105:21
--> $DIR/or_fun_call.rs:104:21
|
LL | let _ = Some(1).unwrap_or(map[&1]);
| ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])`

error: use of `or` followed by a function call
--> $DIR/or_fun_call.rs:129:35
--> $DIR/or_fun_call.rs:128:35
|
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`

error: use of `or` followed by a function call
--> $DIR/or_fun_call.rs:133:10
--> $DIR/or_fun_call.rs:132:10
|
LL | .or(Some(Bar(b, Duration::from_secs(2))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:161:14
--> $DIR/or_fun_call.rs:160:14
|
LL | None.unwrap_or(s.as_mut_vec());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| s.as_mut_vec())`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:166:14
--> $DIR/or_fun_call.rs:165:14
|
LL | None.unwrap_or(unsafe { s.as_mut_vec() });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:168:14
--> $DIR/or_fun_call.rs:167:14
|
LL | None.unwrap_or( unsafe { s.as_mut_vec() } );
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { s.as_mut_vec() })`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/to_string_in_display.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(clippy::to_string_in_display)]
#![allow(clippy::inherent_to_string_shadow_display, clippy::same_name_method)]
#![allow(clippy::inherent_to_string_shadow_display)]

use std::fmt;

Expand Down
1 change: 0 additions & 1 deletion tests/ui/unwrap_or_else_default.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![warn(clippy::unwrap_or_else_default)]
#![allow(dead_code)]
#![allow(clippy::unnecessary_wraps)]
#![allow(clippy::same_name_method)]

/// Checks implementation of the `UNWRAP_OR_ELSE_DEFAULT` lint.
fn unwrap_or_else_default() {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/unwrap_or_else_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![warn(clippy::unwrap_or_else_default)]
#![allow(dead_code)]
#![allow(clippy::unnecessary_wraps)]
#![allow(clippy::same_name_method)]

/// Checks implementation of the `UNWRAP_OR_ELSE_DEFAULT` lint.
fn unwrap_or_else_default() {
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/unwrap_or_else_default.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: use of `.unwrap_or_else(..)` to construct default value
--> $DIR/unwrap_or_else_default.rs:63:5
--> $DIR/unwrap_or_else_default.rs:62:5
|
LL | with_real_default.unwrap_or_else(<HasDefaultAndDuplicate as Default>::default);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_real_default.unwrap_or_default()`
|
= note: `-D clippy::unwrap-or-else-default` implied by `-D warnings`

error: use of `.unwrap_or_else(..)` to construct default value
--> $DIR/unwrap_or_else_default.rs:66:5
--> $DIR/unwrap_or_else_default.rs:65:5
|
LL | with_default_trait.unwrap_or_else(Default::default);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_default_trait.unwrap_or_default()`

error: use of `.unwrap_or_else(..)` to construct default value
--> $DIR/unwrap_or_else_default.rs:69:5
--> $DIR/unwrap_or_else_default.rs:68:5
|
LL | with_default_type.unwrap_or_else(u64::default);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_default_type.unwrap_or_default()`
Expand Down

0 comments on commit c81cd9a

Please sign in to comment.