Downgrade trivially_copy_pass_by_ref to pedantic

This commit is contained in:
David Tolnay 2020-04-02 18:46:01 -07:00
parent 949a5bab33
commit 94154cad20
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
33 changed files with 135 additions and 139 deletions

View File

@ -1119,6 +1119,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&shadow::SHADOW_UNRELATED),
LintId::of(&strings::STRING_ADD_ASSIGN),
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_POSSIBLE_TRUNCATION),
LintId::of(&types::CAST_POSSIBLE_WRAP),
@ -1365,7 +1366,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
LintId::of(&transmute::WRONG_TRANSMUTE),
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(&types::ABSURD_EXTREME_COMPARISONS),
LintId::of(&types::BORROWED_BOX),
@ -1660,7 +1660,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&mutex_atomic::MUTEX_ATOMIC),
LintId::of(&redundant_clone::REDUNDANT_CLONE),
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::REDUNDANT_ALLOCATION),
LintId::of(&vec::USELESS_VEC),

View File

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

View File

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

View File

@ -1,6 +1,7 @@
// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
#![deny(clippy::trivially_copy_pass_by_ref)]
#![allow(clippy::many_single_char_names)]
#[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)
--> $DIR/test.rs:14:11
--> $DIR/test.rs:15:11
|
LL | fn bad(x: &u16, y: &Foo) {}
| ^^^^ 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)
--> $DIR/test.rs:14:20
--> $DIR/test.rs:15:20
|
LL | fn bad(x: &u16, y: &Foo) {}
| ^^^^ help: consider passing by value instead: `Foo`

View File

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

View File

@ -2,7 +2,7 @@
#![feature(custom_inner_attributes)]
#![rustfmt::skip]
#![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;

View File

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

View File

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

View File

@ -1,5 +1,5 @@
error: redundant closure found
--> $DIR/eta.rs:21:27
--> $DIR/eta.rs:20:27
|
LL | let a = Some(1u8).map(|a| foo(a));
| ^^^^^^^^^^ 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`
error: redundant closure found
--> $DIR/eta.rs:22:10
--> $DIR/eta.rs:21:10
|
LL | meta(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown: `foo`
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
| ^^^ 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`
error: redundant closure found
--> $DIR/eta.rs:32:27
--> $DIR/eta.rs:31:27
|
LL | let e = Some(1u8).map(|a| generic(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
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());
| ^^^^^^^^^^^ 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`
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());
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `TestTrait::trait_foo`
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());
| ^^^^^^^^^^^^^ help: remove closure as shown: `std::vec::Vec::clear`
error: redundant closure found
--> $DIR/eta.rs:85:29
--> $DIR/eta.rs:84:29
|
LL | let e = Some("str").map(|s| s.to_string());
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::ToString::to_string`
error: redundant closure found
--> $DIR/eta.rs:87:27
--> $DIR/eta.rs:86:27
|
LL | let e = Some('a').map(|s| s.to_uppercase());
| ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_uppercase`
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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_ascii_uppercase`
error: redundant closure found
--> $DIR/eta.rs:173:27
--> $DIR/eta.rs:172:27
|
LL | let a = Some(1u8).map(|a| foo_ptr(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `foo_ptr`
error: redundant closure found
--> $DIR/eta.rs:178:27
--> $DIR/eta.rs:177:27
|
LL | let a = Some(1u8).map(|a| closure(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `closure`

View File

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

View File

@ -1,5 +1,5 @@
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) {}
| ^^
@ -7,19 +7,19 @@ LL | fn unused_lt<'a>(x: u8) {}
= note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
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) {
| ^^
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) {}
| ^^
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) {}
| ^^

View File

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

View File

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

View File

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

View File

@ -1,29 +1,29 @@
error: infinite iteration detected
--> $DIR/infinite_iter.rs:10:5
--> $DIR/infinite_iter.rs:9:5
|
LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/infinite_iter.rs:8:8
--> $DIR/infinite_iter.rs:7:8
|
LL | #[deny(clippy::infinite_iter)]
| ^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected
--> $DIR/infinite_iter.rs:17:5
--> $DIR/infinite_iter.rs:16:5
|
LL | / (0..8_u32)
LL | | .rev()
@ -33,37 +33,37 @@ LL | | .for_each(|x| println!("{}", x)); // infinite iter
| |________________________________________^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
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)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: possible infinite iteration detected
--> $DIR/infinite_iter.rs:33:5
--> $DIR/infinite_iter.rs:32:5
|
LL | / (1..)
LL | | .scan(0, |state, x| {
@ -74,31 +74,31 @@ LL | | .min(); // maybe infinite iter
| |______________^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^
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
| ^^^^^^^^^^^^^^^^^^^^^^
error: infinite iteration detected
--> $DIR/infinite_iter.rs:65:31
--> $DIR/infinite_iter.rs:64:31
|
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 {
unimplemented!()
}

View File

@ -1,5 +1,5 @@
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 {
| ^^^^^^
@ -8,7 +8,7 @@ LL | while y < 10 {
= 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
--> $DIR/infinite_loop.rs:28:11
--> $DIR/infinite_loop.rs:26:11
|
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
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 {
| ^^^^^
@ -24,7 +24,7 @@ LL | while !cond {
= 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
--> $DIR/infinite_loop.rs:79:11
--> $DIR/infinite_loop.rs:77:11
|
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
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 {
| ^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 {
= 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
--> $DIR/infinite_loop.rs:88:11
--> $DIR/infinite_loop.rs:86:11
|
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
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 {
| ^^^^^
@ -56,7 +56,7 @@ LL | while i < 3 {
= 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
--> $DIR/infinite_loop.rs:108:11
--> $DIR/infinite_loop.rs:106:11
|
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
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 {
| ^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL | while self.count < n {
= 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
--> $DIR/infinite_loop.rs:182:11
--> $DIR/infinite_loop.rs:180:11
|
LL | while y < 10 {
| ^^^^^^
@ -82,7 +82,7 @@ LL | while y < 10 {
= help: rewrite it as `if cond { loop { } }`
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 {
| ^^^^^^

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#![allow(unused, clippy::trivially_copy_pass_by_ref)]
#![allow(unused)]
#![warn(clippy::mut_from_ref)]
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_a_mutable_reference(a: &mut i32) {}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
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);
| ^^^ help: change this to: `&a`
@ -7,19 +7,19 @@ LL | let c = x(&&a);
= note: `-D clippy::needless-borrow` implied by `-D warnings`
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) {}
| ^^^^^^^^ help: change this to: `cake`
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,
| ^^^ help: change this to: `&a`
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());
| ^^^^^ help: change this to: `a`

View File

@ -1,5 +1,5 @@
#![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) {}

View File

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

View File

@ -1,6 +1,7 @@
// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
#![deny(clippy::trivially_copy_pass_by_ref)]
#![allow(
clippy::many_single_char_names,
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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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) {}
| ^^^^ 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)
--> $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);
| ^^^^ 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)
--> $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);
| ^^^^^^ help: consider passing by value instead: `Color`

View File

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

View File

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

View File

@ -1,5 +1,5 @@
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());
| ^^^^^^^^^^^^^ help: try this: `rstr`
@ -11,61 +11,61 @@ LL | #![deny(clippy::useless_asref)]
| ^^^^^^^^^^^^^^^^^^^^^
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());
| ^^^^^^^^^^^^^^^ help: try this: `rslice`
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());
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
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());
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
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());
| ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice`
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());
| ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr`
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());
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
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());
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
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());
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)`
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());
| ^^^^^^^^^^^^ help: try this: `mrt`
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());
| ^^^^^^^^^^^^ help: try this: `mrt`

View File

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