Rollup merge of #5410 - dtolnay:trivially, r=flip1995

Downgrade trivially_copy_pass_by_ref to pedantic

The rationale for this lint is documented as:

> In many calling conventions instances of structs will be passed through registers if they fit into two or less general purpose registers.

I think the purported performance benefits of clippy's recommendation are overstated. This isn't worth asking people to sprinkle code with more `*`​`*`​`&`​`*`​`&` to chase the alleged performance.

This should be a pedantic lint that is disabled by default and opted in if some specific performance sensitive codebase determines that it is worthwhile.

As a reminder, a typical place that a reference to a primitive would come up is if the function is used as a filter. Triggering a performance-oriented lint on this type of code is the definition of pedantic.

```rust
fn filter(_n: &i32) -> bool {
    true
}

fn main() {
    let v = vec![1, 2, 3];
    v.iter().copied().filter(filter).for_each(drop);
}
```

```console
warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
 --> src/main.rs:1:15
  |
1 | fn filter(_n: &i32) -> bool {
  |               ^^^^ help: consider passing by value instead: `i32`
```

changelog: Remove trivially_copy_pass_by_ref from default set of enabled lints
This commit is contained in:
Philipp Krones 2020-04-08 15:50:17 +02:00 committed by GitHub
commit 1e1bd519a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 135 additions and 139 deletions

View file

@ -1125,6 +1125,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&shadow::SHADOW_UNRELATED), LintId::of(&shadow::SHADOW_UNRELATED),
LintId::of(&strings::STRING_ADD_ASSIGN), LintId::of(&strings::STRING_ADD_ASSIGN),
LintId::of(&trait_bounds::TYPE_REPETITION_IN_BOUNDS), LintId::of(&trait_bounds::TYPE_REPETITION_IN_BOUNDS),
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
LintId::of(&types::CAST_LOSSLESS), LintId::of(&types::CAST_LOSSLESS),
LintId::of(&types::CAST_POSSIBLE_TRUNCATION), LintId::of(&types::CAST_POSSIBLE_TRUNCATION),
LintId::of(&types::CAST_POSSIBLE_WRAP), LintId::of(&types::CAST_POSSIBLE_WRAP),
@ -1372,7 +1373,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE), LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
LintId::of(&transmute::WRONG_TRANSMUTE), LintId::of(&transmute::WRONG_TRANSMUTE),
LintId::of(&transmuting_null::TRANSMUTING_NULL), LintId::of(&transmuting_null::TRANSMUTING_NULL),
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
LintId::of(&try_err::TRY_ERR), LintId::of(&try_err::TRY_ERR),
LintId::of(&types::ABSURD_EXTREME_COMPARISONS), LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
LintId::of(&types::BORROWED_BOX), LintId::of(&types::BORROWED_BOX),
@ -1665,7 +1665,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&mutex_atomic::MUTEX_ATOMIC), LintId::of(&mutex_atomic::MUTEX_ATOMIC),
LintId::of(&redundant_clone::REDUNDANT_CLONE), LintId::of(&redundant_clone::REDUNDANT_CLONE),
LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION), LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
LintId::of(&types::BOX_VEC), LintId::of(&types::BOX_VEC),
LintId::of(&types::REDUNDANT_ALLOCATION), LintId::of(&types::REDUNDANT_ALLOCATION),
LintId::of(&vec::USELESS_VEC), LintId::of(&vec::USELESS_VEC),

View file

@ -49,7 +49,7 @@ declare_clippy_lint! {
/// fn foo(v: u32) {} /// fn foo(v: u32) {}
/// ``` /// ```
pub TRIVIALLY_COPY_PASS_BY_REF, pub TRIVIALLY_COPY_PASS_BY_REF,
perf, pedantic,
"functions taking small copyable arguments by reference" "functions taking small copyable arguments by reference"
} }

View file

@ -2161,7 +2161,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
}, },
Lint { Lint {
name: "trivially_copy_pass_by_ref", name: "trivially_copy_pass_by_ref",
group: "perf", group: "pedantic",
desc: "functions taking small copyable arguments by reference", desc: "functions taking small copyable arguments by reference",
deprecation: None, deprecation: None,
module: "trivially_copy_pass_by_ref", module: "trivially_copy_pass_by_ref",

View file

@ -1,6 +1,7 @@
// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)" // normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)" // normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
#![deny(clippy::trivially_copy_pass_by_ref)]
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View file

@ -1,13 +1,17 @@
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/test.rs:14:11 --> $DIR/test.rs:15:11
| |
LL | fn bad(x: &u16, y: &Foo) {} LL | fn bad(x: &u16, y: &Foo) {}
| ^^^^ help: consider passing by value instead: `u16` | ^^^^ help: consider passing by value instead: `u16`
| |
= note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` note: the lint level is defined here
--> $DIR/test.rs:4:9
|
LL | #![deny(clippy::trivially_copy_pass_by_ref)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/test.rs:14:20 --> $DIR/test.rs:15:20
| |
LL | fn bad(x: &u16, y: &Foo) {} LL | fn bad(x: &u16, y: &Foo) {}
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`

View file

@ -5,7 +5,6 @@ pub fn dec_read_dec(i: &mut i32) -> i32 {
ret ret
} }
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn minus_1(i: &i32) -> i32 { pub fn minus_1(i: &i32) -> i32 {
dec_read_dec(&mut i.clone()) dec_read_dec(&mut i.clone())
} }

View file

@ -2,7 +2,7 @@
#![feature(custom_inner_attributes)] #![feature(custom_inner_attributes)]
#![rustfmt::skip] #![rustfmt::skip]
#![warn(clippy::debug_assert_with_mut_call)] #![warn(clippy::debug_assert_with_mut_call)]
#![allow(clippy::trivially_copy_pass_by_ref, clippy::cognitive_complexity, clippy::redundant_closure_call)] #![allow(clippy::cognitive_complexity, clippy::redundant_closure_call)]
struct S; struct S;

View file

@ -6,8 +6,7 @@
clippy::redundant_closure_call, clippy::redundant_closure_call,
clippy::many_single_char_names, clippy::many_single_char_names,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
clippy::option_map_unit_fn, clippy::option_map_unit_fn
clippy::trivially_copy_pass_by_ref
)] )]
#![warn( #![warn(
clippy::redundant_closure, clippy::redundant_closure,

View file

@ -6,8 +6,7 @@
clippy::redundant_closure_call, clippy::redundant_closure_call,
clippy::many_single_char_names, clippy::many_single_char_names,
clippy::needless_pass_by_value, clippy::needless_pass_by_value,
clippy::option_map_unit_fn, clippy::option_map_unit_fn
clippy::trivially_copy_pass_by_ref
)] )]
#![warn( #![warn(
clippy::redundant_closure, clippy::redundant_closure,

View file

@ -1,5 +1,5 @@
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:21:27 --> $DIR/eta.rs:20:27
| |
LL | let a = Some(1u8).map(|a| foo(a)); LL | let a = Some(1u8).map(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown: `foo` | ^^^^^^^^^^ help: remove closure as shown: `foo`
@ -7,13 +7,13 @@ LL | let a = Some(1u8).map(|a| foo(a));
= note: `-D clippy::redundant-closure` implied by `-D warnings` = note: `-D clippy::redundant-closure` implied by `-D warnings`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:22:10 --> $DIR/eta.rs:21:10
| |
LL | meta(|a| foo(a)); LL | meta(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown: `foo` | ^^^^^^^^^^ help: remove closure as shown: `foo`
error: this expression borrows a reference that is immediately dereferenced by the compiler error: this expression borrows a reference that is immediately dereferenced by the compiler
--> $DIR/eta.rs:25:21 --> $DIR/eta.rs:24:21
| |
LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
| ^^^ help: change this to: `&2` | ^^^ help: change this to: `&2`
@ -21,13 +21,13 @@ LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
= note: `-D clippy::needless-borrow` implied by `-D warnings` = note: `-D clippy::needless-borrow` implied by `-D warnings`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:32:27 --> $DIR/eta.rs:31:27
| |
LL | let e = Some(1u8).map(|a| generic(a)); LL | let e = Some(1u8).map(|a| generic(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:75:51 --> $DIR/eta.rs:74:51
| |
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
| ^^^^^^^^^^^ help: remove closure as shown: `TestStruct::foo` | ^^^^^^^^^^^ help: remove closure as shown: `TestStruct::foo`
@ -35,43 +35,43 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
= note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings` = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:77:51 --> $DIR/eta.rs:76:51
| |
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `TestTrait::trait_foo` | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `TestTrait::trait_foo`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:80:42 --> $DIR/eta.rs:79:42
| |
LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
| ^^^^^^^^^^^^^ help: remove closure as shown: `std::vec::Vec::clear` | ^^^^^^^^^^^^^ help: remove closure as shown: `std::vec::Vec::clear`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:85:29 --> $DIR/eta.rs:84:29
| |
LL | let e = Some("str").map(|s| s.to_string()); LL | let e = Some("str").map(|s| s.to_string());
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::ToString::to_string` | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::ToString::to_string`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:87:27 --> $DIR/eta.rs:86:27
| |
LL | let e = Some('a').map(|s| s.to_uppercase()); LL | let e = Some('a').map(|s| s.to_uppercase());
| ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_uppercase` | ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_uppercase`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:90:65 --> $DIR/eta.rs:89:65
| |
LL | let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); LL | let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_ascii_uppercase` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_ascii_uppercase`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:173:27 --> $DIR/eta.rs:172:27
| |
LL | let a = Some(1u8).map(|a| foo_ptr(a)); LL | let a = Some(1u8).map(|a| foo_ptr(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `foo_ptr` | ^^^^^^^^^^^^^^ help: remove closure as shown: `foo_ptr`
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:178:27 --> $DIR/eta.rs:177:27
| |
LL | let a = Some(1u8).map(|a| closure(a)); LL | let a = Some(1u8).map(|a| closure(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `closure` | ^^^^^^^^^^^^^^ help: remove closure as shown: `closure`

View file

@ -2,8 +2,7 @@
unused, unused,
dead_code, dead_code,
clippy::needless_lifetimes, clippy::needless_lifetimes,
clippy::needless_pass_by_value, clippy::needless_pass_by_value
clippy::trivially_copy_pass_by_ref
)] )]
#![warn(clippy::extra_unused_lifetimes)] #![warn(clippy::extra_unused_lifetimes)]

View file

@ -1,5 +1,5 @@
error: this lifetime isn't used in the function definition error: this lifetime isn't used in the function definition
--> $DIR/extra_unused_lifetimes.rs:14:14 --> $DIR/extra_unused_lifetimes.rs:13:14
| |
LL | fn unused_lt<'a>(x: u8) {} LL | fn unused_lt<'a>(x: u8) {}
| ^^ | ^^
@ -7,19 +7,19 @@ LL | fn unused_lt<'a>(x: u8) {}
= note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
error: this lifetime isn't used in the function definition error: this lifetime isn't used in the function definition
--> $DIR/extra_unused_lifetimes.rs:16:25 --> $DIR/extra_unused_lifetimes.rs:15:25
| |
LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
| ^^ | ^^
error: this lifetime isn't used in the function definition error: this lifetime isn't used in the function definition
--> $DIR/extra_unused_lifetimes.rs:41:10 --> $DIR/extra_unused_lifetimes.rs:40:10
| |
LL | fn x<'a>(&self) {} LL | fn x<'a>(&self) {}
| ^^ | ^^
error: this lifetime isn't used in the function definition error: this lifetime isn't used in the function definition
--> $DIR/extra_unused_lifetimes.rs:67:22 --> $DIR/extra_unused_lifetimes.rs:66:22
| |
LL | fn unused_lt<'a>(x: u8) {} LL | fn unused_lt<'a>(x: u8) {}
| ^^ | ^^

View file

@ -5,8 +5,7 @@
clippy::shadow_unrelated, clippy::shadow_unrelated,
clippy::no_effect, clippy::no_effect,
clippy::unnecessary_operation, clippy::unnecessary_operation,
clippy::op_ref, clippy::op_ref
clippy::trivially_copy_pass_by_ref
)] )]
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -1,5 +1,5 @@
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:16:5 --> $DIR/float_arithmetic.rs:15:5
| |
LL | f * 2.0; LL | f * 2.0;
| ^^^^^^^ | ^^^^^^^
@ -7,97 +7,97 @@ LL | f * 2.0;
= note: `-D clippy::float-arithmetic` implied by `-D warnings` = note: `-D clippy::float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:18:5 --> $DIR/float_arithmetic.rs:17:5
| |
LL | 1.0 + f; LL | 1.0 + f;
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:19:5 --> $DIR/float_arithmetic.rs:18:5
| |
LL | f * 2.0; LL | f * 2.0;
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:20:5 --> $DIR/float_arithmetic.rs:19:5
| |
LL | f / 2.0; LL | f / 2.0;
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:21:5 --> $DIR/float_arithmetic.rs:20:5
| |
LL | f - 2.0 * 4.2; LL | f - 2.0 * 4.2;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:22:5 --> $DIR/float_arithmetic.rs:21:5
| |
LL | -f; LL | -f;
| ^^ | ^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:24:5 --> $DIR/float_arithmetic.rs:23:5
| |
LL | f += 1.0; LL | f += 1.0;
| ^^^^^^^^ | ^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:25:5 --> $DIR/float_arithmetic.rs:24:5
| |
LL | f -= 1.0; LL | f -= 1.0;
| ^^^^^^^^ | ^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:26:5 --> $DIR/float_arithmetic.rs:25:5
| |
LL | f *= 2.0; LL | f *= 2.0;
| ^^^^^^^^ | ^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:27:5 --> $DIR/float_arithmetic.rs:26:5
| |
LL | f /= 2.0; LL | f /= 2.0;
| ^^^^^^^^ | ^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:33:5 --> $DIR/float_arithmetic.rs:32:5
| |
LL | 3.1_f32 + &1.2_f32; LL | 3.1_f32 + &1.2_f32;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:34:5 --> $DIR/float_arithmetic.rs:33:5
| |
LL | &3.4_f32 + 1.5_f32; LL | &3.4_f32 + 1.5_f32;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:35:5 --> $DIR/float_arithmetic.rs:34:5
| |
LL | &3.5_f32 + &1.3_f32; LL | &3.5_f32 + &1.3_f32;
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:40:5 --> $DIR/float_arithmetic.rs:39:5
| |
LL | a + f LL | a + f
| ^^^^^ | ^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:44:5 --> $DIR/float_arithmetic.rs:43:5
| |
LL | f1 + f2 LL | f1 + f2
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:48:5 --> $DIR/float_arithmetic.rs:47:5
| |
LL | f1 + f2 LL | f1 + f2
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/float_arithmetic.rs:52:5 --> $DIR/float_arithmetic.rs:51:5
| |
LL | (&f1 + &f2) LL | (&f1 + &f2)
| ^^^^^^^^^^^ | ^^^^^^^^^^^

View file

@ -1,5 +1,4 @@
use std::iter::repeat; use std::iter::repeat;
#[allow(clippy::trivially_copy_pass_by_ref)]
fn square_is_lower_64(x: &u32) -> bool { fn square_is_lower_64(x: &u32) -> bool {
x * x < 64 x * x < 64
} }

View file

@ -1,29 +1,29 @@
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:10:5 --> $DIR/infinite_iter.rs:9:5
| |
LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/infinite_iter.rs:8:8 --> $DIR/infinite_iter.rs:7:8
| |
LL | #[deny(clippy::infinite_iter)] LL | #[deny(clippy::infinite_iter)]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:11:5 --> $DIR/infinite_iter.rs:10:5
| |
LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:12:5 --> $DIR/infinite_iter.rs:11:5
| |
LL | (0..8_u64).chain(0..).max(); // infinite iter LL | (0..8_u64).chain(0..).max(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:17:5 --> $DIR/infinite_iter.rs:16:5
| |
LL | / (0..8_u32) LL | / (0..8_u32)
LL | | .rev() LL | | .rev()
@ -33,37 +33,37 @@ LL | | .for_each(|x| println!("{}", x)); // infinite iter
| |________________________________________^ | |________________________________________^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:23:5 --> $DIR/infinite_iter.rs:22:5
| |
LL | (0_usize..).flat_map(|x| 0..x).product::<usize>(); // infinite iter LL | (0_usize..).flat_map(|x| 0..x).product::<usize>(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:24:5 --> $DIR/infinite_iter.rs:23:5
| |
LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:31:5 --> $DIR/infinite_iter.rs:30:5
| |
LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/infinite_iter.rs:29:8 --> $DIR/infinite_iter.rs:28:8
| |
LL | #[deny(clippy::maybe_infinite_iter)] LL | #[deny(clippy::maybe_infinite_iter)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:32:5 --> $DIR/infinite_iter.rs:31:5
| |
LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:33:5 --> $DIR/infinite_iter.rs:32:5
| |
LL | / (1..) LL | / (1..)
LL | | .scan(0, |state, x| { LL | | .scan(0, |state, x| {
@ -74,31 +74,31 @@ LL | | .min(); // maybe infinite iter
| |______________^ | |______________^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:39:5 --> $DIR/infinite_iter.rs:38:5
| |
LL | (0..).find(|x| *x == 24); // maybe infinite iter LL | (0..).find(|x| *x == 24); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:40:5 --> $DIR/infinite_iter.rs:39:5
| |
LL | (0..).position(|x| x == 24); // maybe infinite iter LL | (0..).position(|x| x == 24); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:41:5 --> $DIR/infinite_iter.rs:40:5
| |
LL | (0..).any(|x| x == 24); // maybe infinite iter LL | (0..).any(|x| x == 24); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:42:5 --> $DIR/infinite_iter.rs:41:5
| |
LL | (0..).all(|x| x == 24); // maybe infinite iter LL | (0..).all(|x| x == 24); // maybe infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected error: infinite iteration detected
--> $DIR/infinite_iter.rs:65:31 --> $DIR/infinite_iter.rs:64:31
| |
LL | let _: HashSet<i32> = (0..).collect(); // Infinite iter LL | let _: HashSet<i32> = (0..).collect(); // Infinite iter
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^

View file

@ -1,5 +1,3 @@
#![allow(clippy::trivially_copy_pass_by_ref)]
fn fn_val(i: i32) -> i32 { fn fn_val(i: i32) -> i32 {
unimplemented!() unimplemented!()
} }

View file

@ -1,5 +1,5 @@
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:23:11 --> $DIR/infinite_loop.rs:21:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^
@ -8,7 +8,7 @@ LL | while y < 10 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:28:11 --> $DIR/infinite_loop.rs:26:11
| |
LL | while y < 10 && x < 3 { LL | while y < 10 && x < 3 {
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:35:11 --> $DIR/infinite_loop.rs:33:11
| |
LL | while !cond { LL | while !cond {
| ^^^^^ | ^^^^^
@ -24,7 +24,7 @@ LL | while !cond {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:79:11 --> $DIR/infinite_loop.rs:77:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -32,7 +32,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:84:11 --> $DIR/infinite_loop.rs:82:11
| |
LL | while i < 3 && j > 0 { LL | while i < 3 && j > 0 {
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:88:11 --> $DIR/infinite_loop.rs:86:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -48,7 +48,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:103:11 --> $DIR/infinite_loop.rs:101:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -56,7 +56,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:108:11 --> $DIR/infinite_loop.rs:106:11
| |
LL | while i < 3 { LL | while i < 3 {
| ^^^^^ | ^^^^^
@ -64,7 +64,7 @@ LL | while i < 3 {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:174:15 --> $DIR/infinite_loop.rs:172:15
| |
LL | while self.count < n { LL | while self.count < n {
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | while self.count < n {
= note: this may lead to an infinite or to a never running loop = note: this may lead to an infinite or to a never running loop
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:182:11 --> $DIR/infinite_loop.rs:180:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^
@ -82,7 +82,7 @@ LL | while y < 10 {
= help: rewrite it as `if cond { loop { } }` = help: rewrite it as `if cond { loop { } }`
error: variables in the condition are not mutated in the loop body error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:189:11 --> $DIR/infinite_loop.rs:187:11
| |
LL | while y < 10 { LL | while y < 10 {
| ^^^^^^ | ^^^^^^

View file

@ -5,8 +5,7 @@
clippy::shadow_unrelated, clippy::shadow_unrelated,
clippy::no_effect, clippy::no_effect,
clippy::unnecessary_operation, clippy::unnecessary_operation,
clippy::op_ref, clippy::op_ref
clippy::trivially_copy_pass_by_ref
)] )]
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -1,5 +1,5 @@
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:15:5 --> $DIR/integer_arithmetic.rs:14:5
| |
LL | 1 + i; LL | 1 + i;
| ^^^^^ | ^^^^^
@ -7,98 +7,98 @@ LL | 1 + i;
= note: `-D clippy::integer-arithmetic` implied by `-D warnings` = note: `-D clippy::integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:16:5 --> $DIR/integer_arithmetic.rs:15:5
| |
LL | i * 2; LL | i * 2;
| ^^^^^ | ^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:17:5 --> $DIR/integer_arithmetic.rs:16:5
| |
LL | / 1 % LL | / 1 %
LL | | i / 2; // no error, this is part of the expression in the preceding line LL | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^ | |_________^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:19:5 --> $DIR/integer_arithmetic.rs:18:5
| |
LL | i - 2 + 2 - i; LL | i - 2 + 2 - i;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:20:5 --> $DIR/integer_arithmetic.rs:19:5
| |
LL | -i; LL | -i;
| ^^ | ^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:32:5 --> $DIR/integer_arithmetic.rs:31:5
| |
LL | i += 1; LL | i += 1;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:33:5 --> $DIR/integer_arithmetic.rs:32:5
| |
LL | i -= 1; LL | i -= 1;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:34:5 --> $DIR/integer_arithmetic.rs:33:5
| |
LL | i *= 2; LL | i *= 2;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:35:5 --> $DIR/integer_arithmetic.rs:34:5
| |
LL | i /= 2; LL | i /= 2;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:36:5 --> $DIR/integer_arithmetic.rs:35:5
| |
LL | i %= 2; LL | i %= 2;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:82:5 --> $DIR/integer_arithmetic.rs:81:5
| |
LL | 3 + &1; LL | 3 + &1;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:83:5 --> $DIR/integer_arithmetic.rs:82:5
| |
LL | &3 + 1; LL | &3 + 1;
| ^^^^^^ | ^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:84:5 --> $DIR/integer_arithmetic.rs:83:5
| |
LL | &3 + &1; LL | &3 + &1;
| ^^^^^^^ | ^^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:89:5 --> $DIR/integer_arithmetic.rs:88:5
| |
LL | a + x LL | a + x
| ^^^^^ | ^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:93:5 --> $DIR/integer_arithmetic.rs:92:5
| |
LL | x + y LL | x + y
| ^^^^^ | ^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:97:5 --> $DIR/integer_arithmetic.rs:96:5
| |
LL | x + y LL | x + y
| ^^^^^ | ^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/integer_arithmetic.rs:101:5 --> $DIR/integer_arithmetic.rs:100:5
| |
LL | (&x + &y) LL | (&x + &y)
| ^^^^^^^^^ | ^^^^^^^^^

View file

@ -1,4 +1,4 @@
#![allow(unused, clippy::trivially_copy_pass_by_ref)] #![allow(unused)]
#![warn(clippy::mut_from_ref)] #![warn(clippy::mut_from_ref)]
struct Foo; struct Foo;

View file

@ -1,4 +1,4 @@
#![allow(unused_variables, clippy::trivially_copy_pass_by_ref)] #![allow(unused_variables)]
fn takes_an_immutable_reference(a: &i32) {} fn takes_an_immutable_reference(a: &i32) {}
fn takes_a_mutable_reference(a: &mut i32) {} fn takes_a_mutable_reference(a: &mut i32) {}

View file

@ -2,7 +2,6 @@
#![allow(clippy::needless_borrowed_reference)] #![allow(clippy::needless_borrowed_reference)]
#[allow(clippy::trivially_copy_pass_by_ref)]
fn x(y: &i32) -> i32 { fn x(y: &i32) -> i32 {
*y *y
} }

View file

@ -2,7 +2,6 @@
#![allow(clippy::needless_borrowed_reference)] #![allow(clippy::needless_borrowed_reference)]
#[allow(clippy::trivially_copy_pass_by_ref)]
fn x(y: &i32) -> i32 { fn x(y: &i32) -> i32 {
*y *y
} }

View file

@ -1,5 +1,5 @@
error: this expression borrows a reference that is immediately dereferenced by the compiler error: this expression borrows a reference that is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:15:15 --> $DIR/needless_borrow.rs:14:15
| |
LL | let c = x(&&a); LL | let c = x(&&a);
| ^^^ help: change this to: `&a` | ^^^ help: change this to: `&a`
@ -7,19 +7,19 @@ LL | let c = x(&&a);
= note: `-D clippy::needless-borrow` implied by `-D warnings` = note: `-D clippy::needless-borrow` implied by `-D warnings`
error: this pattern creates a reference to a reference error: this pattern creates a reference to a reference
--> $DIR/needless_borrow.rs:22:17 --> $DIR/needless_borrow.rs:21:17
| |
LL | if let Some(ref cake) = Some(&5) {} LL | if let Some(ref cake) = Some(&5) {}
| ^^^^^^^^ help: change this to: `cake` | ^^^^^^^^ help: change this to: `cake`
error: this expression borrows a reference that is immediately dereferenced by the compiler error: this expression borrows a reference that is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:29:15 --> $DIR/needless_borrow.rs:28:15
| |
LL | 46 => &&a, LL | 46 => &&a,
| ^^^ help: change this to: `&a` | ^^^ help: change this to: `&a`
error: this pattern creates a reference to a reference error: this pattern creates a reference to a reference
--> $DIR/needless_borrow.rs:52:31 --> $DIR/needless_borrow.rs:51:31
| |
LL | let _ = v.iter().filter(|&ref a| a.is_empty()); LL | let _ = v.iter().filter(|&ref a| a.is_empty());
| ^^^^^ help: change this to: `a` | ^^^^^ help: change this to: `a`

View file

@ -1,5 +1,5 @@
#![warn(clippy::needless_lifetimes)] #![warn(clippy::needless_lifetimes)]
#![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] #![allow(dead_code, clippy::needless_pass_by_value)]
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}

View file

@ -1,5 +1,5 @@
#![warn(clippy::new_ret_no_self)] #![warn(clippy::new_ret_no_self)]
#![allow(dead_code, clippy::trivially_copy_pass_by_ref)] #![allow(dead_code)]
fn main() {} fn main() {}

View file

@ -1,6 +1,7 @@
// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)" // normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)" // normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
#![deny(clippy::trivially_copy_pass_by_ref)]
#![allow( #![allow(
clippy::many_single_char_names, clippy::many_single_char_names,
clippy::blacklisted_name, clippy::blacklisted_name,

View file

@ -1,91 +1,95 @@
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:50:11 --> $DIR/trivially_copy_pass_by_ref.rs:51:11
| |
LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `u32` | ^^^^ help: consider passing by value instead: `u32`
| |
= note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` note: the lint level is defined here
--> $DIR/trivially_copy_pass_by_ref.rs:4:9
|
LL | #![deny(clippy::trivially_copy_pass_by_ref)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:50:20 --> $DIR/trivially_copy_pass_by_ref.rs:51:20
| |
LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:50:29 --> $DIR/trivially_copy_pass_by_ref.rs:51:29
| |
LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Baz` | ^^^^ help: consider passing by value instead: `Baz`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:57:12 --> $DIR/trivially_copy_pass_by_ref.rs:58:12
| |
LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
| ^^^^^ help: consider passing by value instead: `self` | ^^^^^ help: consider passing by value instead: `self`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:57:22 --> $DIR/trivially_copy_pass_by_ref.rs:58:22
| |
LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `u32` | ^^^^ help: consider passing by value instead: `u32`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:57:31 --> $DIR/trivially_copy_pass_by_ref.rs:58:31
| |
LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:57:40 --> $DIR/trivially_copy_pass_by_ref.rs:58:40
| |
LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Baz` | ^^^^ help: consider passing by value instead: `Baz`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:59:16 --> $DIR/trivially_copy_pass_by_ref.rs:60:16
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `u32` | ^^^^ help: consider passing by value instead: `u32`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:59:25 --> $DIR/trivially_copy_pass_by_ref.rs:60:25
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:59:34 --> $DIR/trivially_copy_pass_by_ref.rs:60:34
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Baz` | ^^^^ help: consider passing by value instead: `Baz`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:71:16 --> $DIR/trivially_copy_pass_by_ref.rs:72:16
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `u32` | ^^^^ help: consider passing by value instead: `u32`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:71:25 --> $DIR/trivially_copy_pass_by_ref.rs:72:25
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:71:34 --> $DIR/trivially_copy_pass_by_ref.rs:72:34
| |
LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {}
| ^^^^ help: consider passing by value instead: `Baz` | ^^^^ help: consider passing by value instead: `Baz`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:75:34 --> $DIR/trivially_copy_pass_by_ref.rs:76:34
| |
LL | fn trait_method(&self, _foo: &Foo); LL | fn trait_method(&self, _foo: &Foo);
| ^^^^ help: consider passing by value instead: `Foo` | ^^^^ help: consider passing by value instead: `Foo`
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
--> $DIR/trivially_copy_pass_by_ref.rs:79:37 --> $DIR/trivially_copy_pass_by_ref.rs:80:37
| |
LL | fn trait_method2(&self, _color: &Color); LL | fn trait_method2(&self, _color: &Color);
| ^^^^^^ help: consider passing by value instead: `Color` | ^^^^^^ help: consider passing by value instead: `Color`

View file

@ -1,7 +1,6 @@
// run-rustfix // run-rustfix
#![deny(clippy::useless_asref)] #![deny(clippy::useless_asref)]
#![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt::Debug; use std::fmt::Debug;

View file

@ -1,7 +1,6 @@
// run-rustfix // run-rustfix
#![deny(clippy::useless_asref)] #![deny(clippy::useless_asref)]
#![allow(clippy::trivially_copy_pass_by_ref)]
use std::fmt::Debug; use std::fmt::Debug;

View file

@ -1,5 +1,5 @@
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:44:18 --> $DIR/useless_asref.rs:43:18
| |
LL | foo_rstr(rstr.as_ref()); LL | foo_rstr(rstr.as_ref());
| ^^^^^^^^^^^^^ help: try this: `rstr` | ^^^^^^^^^^^^^ help: try this: `rstr`
@ -11,61 +11,61 @@ LL | #![deny(clippy::useless_asref)]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:46:20 --> $DIR/useless_asref.rs:45:20
| |
LL | foo_rslice(rslice.as_ref()); LL | foo_rslice(rslice.as_ref());
| ^^^^^^^^^^^^^^^ help: try this: `rslice` | ^^^^^^^^^^^^^^^ help: try this: `rslice`
error: this call to `as_mut` does nothing error: this call to `as_mut` does nothing
--> $DIR/useless_asref.rs:50:21 --> $DIR/useless_asref.rs:49:21
| |
LL | foo_mrslice(mrslice.as_mut()); LL | foo_mrslice(mrslice.as_mut());
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice` | ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:52:20 --> $DIR/useless_asref.rs:51:20
| |
LL | foo_rslice(mrslice.as_ref()); LL | foo_rslice(mrslice.as_ref());
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice` | ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:59:20 --> $DIR/useless_asref.rs:58:20
| |
LL | foo_rslice(rrrrrslice.as_ref()); LL | foo_rslice(rrrrrslice.as_ref());
| ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:61:18 --> $DIR/useless_asref.rs:60:18
| |
LL | foo_rstr(rrrrrstr.as_ref()); LL | foo_rstr(rrrrrstr.as_ref());
| ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr`
error: this call to `as_mut` does nothing error: this call to `as_mut` does nothing
--> $DIR/useless_asref.rs:66:21 --> $DIR/useless_asref.rs:65:21
| |
LL | foo_mrslice(mrrrrrslice.as_mut()); LL | foo_mrslice(mrrrrrslice.as_mut());
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:68:20 --> $DIR/useless_asref.rs:67:20
| |
LL | foo_rslice(mrrrrrslice.as_ref()); LL | foo_rslice(mrrrrrslice.as_ref());
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:72:16 --> $DIR/useless_asref.rs:71:16
| |
LL | foo_rrrrmr((&&&&MoreRef).as_ref()); LL | foo_rrrrmr((&&&&MoreRef).as_ref());
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)`
error: this call to `as_mut` does nothing error: this call to `as_mut` does nothing
--> $DIR/useless_asref.rs:122:13 --> $DIR/useless_asref.rs:121:13
| |
LL | foo_mrt(mrt.as_mut()); LL | foo_mrt(mrt.as_mut());
| ^^^^^^^^^^^^ help: try this: `mrt` | ^^^^^^^^^^^^ help: try this: `mrt`
error: this call to `as_ref` does nothing error: this call to `as_ref` does nothing
--> $DIR/useless_asref.rs:124:12 --> $DIR/useless_asref.rs:123:12
| |
LL | foo_rt(mrt.as_ref()); LL | foo_rt(mrt.as_ref());
| ^^^^^^^^^^^^ help: try this: `mrt` | ^^^^^^^^^^^^ help: try this: `mrt`

View file

@ -1,6 +1,6 @@
#![warn(clippy::wrong_self_convention)] #![warn(clippy::wrong_self_convention)]
#![warn(clippy::wrong_pub_self_convention)] #![warn(clippy::wrong_pub_self_convention)]
#![allow(dead_code, clippy::trivially_copy_pass_by_ref)] #![allow(dead_code)]
fn main() {} fn main() {}