Skip to content

Commit 94154ca

Browse files
committed
Downgrade trivially_copy_pass_by_ref to pedantic
1 parent 949a5ba commit 94154ca

33 files changed

+135
-139
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11191119
LintId::of(&shadow::SHADOW_UNRELATED),
11201120
LintId::of(&strings::STRING_ADD_ASSIGN),
11211121
LintId::of(&trait_bounds::TYPE_REPETITION_IN_BOUNDS),
1122+
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
11221123
LintId::of(&types::CAST_LOSSLESS),
11231124
LintId::of(&types::CAST_POSSIBLE_TRUNCATION),
11241125
LintId::of(&types::CAST_POSSIBLE_WRAP),
@@ -1365,7 +1366,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13651366
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
13661367
LintId::of(&transmute::WRONG_TRANSMUTE),
13671368
LintId::of(&transmuting_null::TRANSMUTING_NULL),
1368-
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
13691369
LintId::of(&try_err::TRY_ERR),
13701370
LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
13711371
LintId::of(&types::BORROWED_BOX),
@@ -1660,7 +1660,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16601660
LintId::of(&mutex_atomic::MUTEX_ATOMIC),
16611661
LintId::of(&redundant_clone::REDUNDANT_CLONE),
16621662
LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
1663-
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
16641663
LintId::of(&types::BOX_VEC),
16651664
LintId::of(&types::REDUNDANT_ALLOCATION),
16661665
LintId::of(&vec::USELESS_VEC),

clippy_lints/src/trivially_copy_pass_by_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare_clippy_lint! {
4949
/// fn foo(v: u32) {}
5050
/// ```
5151
pub TRIVIALLY_COPY_PASS_BY_REF,
52-
perf,
52+
pedantic,
5353
"functions taking small copyable arguments by reference"
5454
}
5555

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
21612161
},
21622162
Lint {
21632163
name: "trivially_copy_pass_by_ref",
2164-
group: "perf",
2164+
group: "pedantic",
21652165
desc: "functions taking small copyable arguments by reference",
21662166
deprecation: None,
21672167
module: "trivially_copy_pass_by_ref",

tests/ui-toml/toml_trivially_copy/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
22
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
33

4+
#![deny(clippy::trivially_copy_pass_by_ref)]
45
#![allow(clippy::many_single_char_names)]
56

67
#[derive(Copy, Clone)]

tests/ui-toml/toml_trivially_copy/test.stderr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
2-
--> $DIR/test.rs:14:11
2+
--> $DIR/test.rs:15:11
33
|
44
LL | fn bad(x: &u16, y: &Foo) {}
55
| ^^^^ help: consider passing by value instead: `u16`
66
|
7-
= note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings`
7+
note: the lint level is defined here
8+
--> $DIR/test.rs:4:9
9+
|
10+
LL | #![deny(clippy::trivially_copy_pass_by_ref)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
812

913
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
10-
--> $DIR/test.rs:14:20
14+
--> $DIR/test.rs:15:20
1115
|
1216
LL | fn bad(x: &u16, y: &Foo) {}
1317
| ^^^^ help: consider passing by value instead: `Foo`

tests/ui/clone_on_copy_mut.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pub fn dec_read_dec(i: &mut i32) -> i32 {
55
ret
66
}
77

8-
#[allow(clippy::trivially_copy_pass_by_ref)]
98
pub fn minus_1(i: &i32) -> i32 {
109
dec_read_dec(&mut i.clone())
1110
}

tests/ui/debug_assert_with_mut_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(custom_inner_attributes)]
33
#![rustfmt::skip]
44
#![warn(clippy::debug_assert_with_mut_call)]
5-
#![allow(clippy::trivially_copy_pass_by_ref, clippy::cognitive_complexity, clippy::redundant_closure_call)]
5+
#![allow(clippy::cognitive_complexity, clippy::redundant_closure_call)]
66

77
struct S;
88

tests/ui/eta.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
clippy::redundant_closure_call,
77
clippy::many_single_char_names,
88
clippy::needless_pass_by_value,
9-
clippy::option_map_unit_fn,
10-
clippy::trivially_copy_pass_by_ref
9+
clippy::option_map_unit_fn
1110
)]
1211
#![warn(
1312
clippy::redundant_closure,

tests/ui/eta.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
clippy::redundant_closure_call,
77
clippy::many_single_char_names,
88
clippy::needless_pass_by_value,
9-
clippy::option_map_unit_fn,
10-
clippy::trivially_copy_pass_by_ref
9+
clippy::option_map_unit_fn
1110
)]
1211
#![warn(
1312
clippy::redundant_closure,

tests/ui/eta.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
11
error: redundant closure found
2-
--> $DIR/eta.rs:21:27
2+
--> $DIR/eta.rs:20:27
33
|
44
LL | let a = Some(1u8).map(|a| foo(a));
55
| ^^^^^^^^^^ help: remove closure as shown: `foo`
66
|
77
= note: `-D clippy::redundant-closure` implied by `-D warnings`
88

99
error: redundant closure found
10-
--> $DIR/eta.rs:22:10
10+
--> $DIR/eta.rs:21:10
1111
|
1212
LL | meta(|a| foo(a));
1313
| ^^^^^^^^^^ help: remove closure as shown: `foo`
1414

1515
error: this expression borrows a reference that is immediately dereferenced by the compiler
16-
--> $DIR/eta.rs:25:21
16+
--> $DIR/eta.rs:24:21
1717
|
1818
LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
1919
| ^^^ help: change this to: `&2`
2020
|
2121
= note: `-D clippy::needless-borrow` implied by `-D warnings`
2222

2323
error: redundant closure found
24-
--> $DIR/eta.rs:32:27
24+
--> $DIR/eta.rs:31:27
2525
|
2626
LL | let e = Some(1u8).map(|a| generic(a));
2727
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
2828

2929
error: redundant closure found
30-
--> $DIR/eta.rs:75:51
30+
--> $DIR/eta.rs:74:51
3131
|
3232
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
3333
| ^^^^^^^^^^^ help: remove closure as shown: `TestStruct::foo`
3434
|
3535
= note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings`
3636

3737
error: redundant closure found
38-
--> $DIR/eta.rs:77:51
38+
--> $DIR/eta.rs:76:51
3939
|
4040
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
4141
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `TestTrait::trait_foo`
4242

4343
error: redundant closure found
44-
--> $DIR/eta.rs:80:42
44+
--> $DIR/eta.rs:79:42
4545
|
4646
LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
4747
| ^^^^^^^^^^^^^ help: remove closure as shown: `std::vec::Vec::clear`
4848

4949
error: redundant closure found
50-
--> $DIR/eta.rs:85:29
50+
--> $DIR/eta.rs:84:29
5151
|
5252
LL | let e = Some("str").map(|s| s.to_string());
5353
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::ToString::to_string`
5454

5555
error: redundant closure found
56-
--> $DIR/eta.rs:87:27
56+
--> $DIR/eta.rs:86:27
5757
|
5858
LL | let e = Some('a').map(|s| s.to_uppercase());
5959
| ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_uppercase`
6060

6161
error: redundant closure found
62-
--> $DIR/eta.rs:90:65
62+
--> $DIR/eta.rs:89:65
6363
|
6464
LL | let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_ascii_uppercase`
6666

6767
error: redundant closure found
68-
--> $DIR/eta.rs:173:27
68+
--> $DIR/eta.rs:172:27
6969
|
7070
LL | let a = Some(1u8).map(|a| foo_ptr(a));
7171
| ^^^^^^^^^^^^^^ help: remove closure as shown: `foo_ptr`
7272

7373
error: redundant closure found
74-
--> $DIR/eta.rs:178:27
74+
--> $DIR/eta.rs:177:27
7575
|
7676
LL | let a = Some(1u8).map(|a| closure(a));
7777
| ^^^^^^^^^^^^^^ help: remove closure as shown: `closure`

tests/ui/extra_unused_lifetimes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
unused,
33
dead_code,
44
clippy::needless_lifetimes,
5-
clippy::needless_pass_by_value,
6-
clippy::trivially_copy_pass_by_ref
5+
clippy::needless_pass_by_value
76
)]
87
#![warn(clippy::extra_unused_lifetimes)]
98

tests/ui/extra_unused_lifetimes.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error: this lifetime isn't used in the function definition
2-
--> $DIR/extra_unused_lifetimes.rs:14:14
2+
--> $DIR/extra_unused_lifetimes.rs:13:14
33
|
44
LL | fn unused_lt<'a>(x: u8) {}
55
| ^^
66
|
77
= note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
88

99
error: this lifetime isn't used in the function definition
10-
--> $DIR/extra_unused_lifetimes.rs:16:25
10+
--> $DIR/extra_unused_lifetimes.rs:15:25
1111
|
1212
LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
1313
| ^^
1414

1515
error: this lifetime isn't used in the function definition
16-
--> $DIR/extra_unused_lifetimes.rs:41:10
16+
--> $DIR/extra_unused_lifetimes.rs:40:10
1717
|
1818
LL | fn x<'a>(&self) {}
1919
| ^^
2020

2121
error: this lifetime isn't used in the function definition
22-
--> $DIR/extra_unused_lifetimes.rs:67:22
22+
--> $DIR/extra_unused_lifetimes.rs:66:22
2323
|
2424
LL | fn unused_lt<'a>(x: u8) {}
2525
| ^^

tests/ui/float_arithmetic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
clippy::shadow_unrelated,
66
clippy::no_effect,
77
clippy::unnecessary_operation,
8-
clippy::op_ref,
9-
clippy::trivially_copy_pass_by_ref
8+
clippy::op_ref
109
)]
1110

1211
#[rustfmt::skip]

tests/ui/float_arithmetic.stderr

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
11
error: floating-point arithmetic detected
2-
--> $DIR/float_arithmetic.rs:16:5
2+
--> $DIR/float_arithmetic.rs:15:5
33
|
44
LL | f * 2.0;
55
| ^^^^^^^
66
|
77
= note: `-D clippy::float-arithmetic` implied by `-D warnings`
88

99
error: floating-point arithmetic detected
10-
--> $DIR/float_arithmetic.rs:18:5
10+
--> $DIR/float_arithmetic.rs:17:5
1111
|
1212
LL | 1.0 + f;
1313
| ^^^^^^^
1414

1515
error: floating-point arithmetic detected
16-
--> $DIR/float_arithmetic.rs:19:5
16+
--> $DIR/float_arithmetic.rs:18:5
1717
|
1818
LL | f * 2.0;
1919
| ^^^^^^^
2020

2121
error: floating-point arithmetic detected
22-
--> $DIR/float_arithmetic.rs:20:5
22+
--> $DIR/float_arithmetic.rs:19:5
2323
|
2424
LL | f / 2.0;
2525
| ^^^^^^^
2626

2727
error: floating-point arithmetic detected
28-
--> $DIR/float_arithmetic.rs:21:5
28+
--> $DIR/float_arithmetic.rs:20:5
2929
|
3030
LL | f - 2.0 * 4.2;
3131
| ^^^^^^^^^^^^^
3232

3333
error: floating-point arithmetic detected
34-
--> $DIR/float_arithmetic.rs:22:5
34+
--> $DIR/float_arithmetic.rs:21:5
3535
|
3636
LL | -f;
3737
| ^^
3838

3939
error: floating-point arithmetic detected
40-
--> $DIR/float_arithmetic.rs:24:5
40+
--> $DIR/float_arithmetic.rs:23:5
4141
|
4242
LL | f += 1.0;
4343
| ^^^^^^^^
4444

4545
error: floating-point arithmetic detected
46-
--> $DIR/float_arithmetic.rs:25:5
46+
--> $DIR/float_arithmetic.rs:24:5
4747
|
4848
LL | f -= 1.0;
4949
| ^^^^^^^^
5050

5151
error: floating-point arithmetic detected
52-
--> $DIR/float_arithmetic.rs:26:5
52+
--> $DIR/float_arithmetic.rs:25:5
5353
|
5454
LL | f *= 2.0;
5555
| ^^^^^^^^
5656

5757
error: floating-point arithmetic detected
58-
--> $DIR/float_arithmetic.rs:27:5
58+
--> $DIR/float_arithmetic.rs:26:5
5959
|
6060
LL | f /= 2.0;
6161
| ^^^^^^^^
6262

6363
error: floating-point arithmetic detected
64-
--> $DIR/float_arithmetic.rs:33:5
64+
--> $DIR/float_arithmetic.rs:32:5
6565
|
6666
LL | 3.1_f32 + &1.2_f32;
6767
| ^^^^^^^^^^^^^^^^^^
6868

6969
error: floating-point arithmetic detected
70-
--> $DIR/float_arithmetic.rs:34:5
70+
--> $DIR/float_arithmetic.rs:33:5
7171
|
7272
LL | &3.4_f32 + 1.5_f32;
7373
| ^^^^^^^^^^^^^^^^^^
7474

7575
error: floating-point arithmetic detected
76-
--> $DIR/float_arithmetic.rs:35:5
76+
--> $DIR/float_arithmetic.rs:34:5
7777
|
7878
LL | &3.5_f32 + &1.3_f32;
7979
| ^^^^^^^^^^^^^^^^^^^
8080

8181
error: floating-point arithmetic detected
82-
--> $DIR/float_arithmetic.rs:40:5
82+
--> $DIR/float_arithmetic.rs:39:5
8383
|
8484
LL | a + f
8585
| ^^^^^
8686

8787
error: floating-point arithmetic detected
88-
--> $DIR/float_arithmetic.rs:44:5
88+
--> $DIR/float_arithmetic.rs:43:5
8989
|
9090
LL | f1 + f2
9191
| ^^^^^^^
9292

9393
error: floating-point arithmetic detected
94-
--> $DIR/float_arithmetic.rs:48:5
94+
--> $DIR/float_arithmetic.rs:47:5
9595
|
9696
LL | f1 + f2
9797
| ^^^^^^^
9898

9999
error: floating-point arithmetic detected
100-
--> $DIR/float_arithmetic.rs:52:5
100+
--> $DIR/float_arithmetic.rs:51:5
101101
|
102102
LL | (&f1 + &f2)
103103
| ^^^^^^^^^^^

tests/ui/infinite_iter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::iter::repeat;
2-
#[allow(clippy::trivially_copy_pass_by_ref)]
32
fn square_is_lower_64(x: &u32) -> bool {
43
x * x < 64
54
}

0 commit comments

Comments
 (0)