mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 09:05:00 +00:00
Update UI tests with new needless_pass_by_ref_mut
lint
This commit is contained in:
parent
a43bea1016
commit
c62c7fadac
@ -2,6 +2,7 @@
|
||||
//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)"
|
||||
|
||||
#![warn(clippy::trivially_copy_pass_by_ref)]
|
||||
#![allow(clippy::needless_pass_by_ref_mut)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Foo(u8);
|
||||
|
@ -1,5 +1,5 @@
|
||||
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`
|
||||
@ -7,7 +7,7 @@ LL | fn bad(x: &u16, y: &Foo) {}
|
||||
= note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings`
|
||||
|
||||
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`
|
||||
|
@ -1,6 +1,10 @@
|
||||
#![deny(clippy::borrowed_box)]
|
||||
#![allow(dead_code, unused_variables)]
|
||||
#![allow(clippy::uninlined_format_args, clippy::disallowed_names)]
|
||||
#![allow(
|
||||
clippy::uninlined_format_args,
|
||||
clippy::disallowed_names,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:20:14
|
||||
--> $DIR/borrow_box.rs:24:14
|
||||
|
|
||||
LL | let foo: &Box<bool>;
|
||||
| ^^^^^^^^^^ help: try: `&bool`
|
||||
@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:24:10
|
||||
--> $DIR/borrow_box.rs:28:10
|
||||
|
|
||||
LL | foo: &'a Box<bool>,
|
||||
| ^^^^^^^^^^^^^ help: try: `&'a bool`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:28:17
|
||||
--> $DIR/borrow_box.rs:32:17
|
||||
|
|
||||
LL | fn test4(a: &Box<bool>);
|
||||
| ^^^^^^^^^^ help: try: `&bool`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:94:25
|
||||
--> $DIR/borrow_box.rs:98:25
|
||||
|
|
||||
LL | pub fn test14(_display: &Box<dyn Display>) {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:95:25
|
||||
--> $DIR/borrow_box.rs:99:25
|
||||
|
|
||||
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:96:29
|
||||
--> $DIR/borrow_box.rs:100:29
|
||||
|
|
||||
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:98:25
|
||||
--> $DIR/borrow_box.rs:102:25
|
||||
|
|
||||
LL | pub fn test17(_display: &Box<impl Display>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:99:25
|
||||
--> $DIR/borrow_box.rs:103:25
|
||||
|
|
||||
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:100:29
|
||||
--> $DIR/borrow_box.rs:104:29
|
||||
|
|
||||
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> $DIR/borrow_box.rs:105:25
|
||||
--> $DIR/borrow_box.rs:109:25
|
||||
|
|
||||
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
@ -1,3 +1,11 @@
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/infinite_loop.rs:7:17
|
||||
|
|
||||
LL | fn fn_mutref(i: &mut i32) {
|
||||
| ^^^^^^^^ help: consider changing to: `&i32`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> $DIR/infinite_loop.rs:20:11
|
||||
|
|
||||
@ -91,5 +99,5 @@ LL | while y < 10 {
|
||||
= note: this loop contains `return`s or `break`s
|
||||
= help: rewrite it as `if cond { loop { } }`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/let_underscore_future.rs:11:35
|
||||
|
|
||||
LL | fn do_something_to_future(future: &mut impl Future<Output = ()>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&impl Future<Output = ()>`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: non-binding `let` on a future
|
||||
--> $DIR/let_underscore_future.rs:14:5
|
||||
|
|
||||
@ -23,5 +31,5 @@ LL | let _ = future;
|
||||
|
|
||||
= help: consider awaiting the future or dropping explicitly with `std::mem::drop`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -1,6 +1,11 @@
|
||||
//@run-rustfix
|
||||
#![feature(never_type)]
|
||||
#![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)]
|
||||
#![allow(
|
||||
unused_mut,
|
||||
unused_tuple_struct_fields,
|
||||
clippy::redundant_allocation,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
#![warn(clippy::must_use_candidate)]
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
@ -1,6 +1,11 @@
|
||||
//@run-rustfix
|
||||
#![feature(never_type)]
|
||||
#![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)]
|
||||
#![allow(
|
||||
unused_mut,
|
||||
unused_tuple_struct_fields,
|
||||
clippy::redundant_allocation,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
#![warn(clippy::must_use_candidate)]
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:12:1
|
||||
--> $DIR/must_use_candidates.rs:17:1
|
||||
|
|
||||
LL | pub fn pure(i: u8) -> u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8`
|
||||
@ -7,25 +7,25 @@ LL | pub fn pure(i: u8) -> u8 {
|
||||
= note: `-D clippy::must-use-candidate` implied by `-D warnings`
|
||||
|
||||
error: this method could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:17:5
|
||||
--> $DIR/must_use_candidates.rs:22:5
|
||||
|
|
||||
LL | pub fn inherent_pure(&self) -> u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:48:1
|
||||
--> $DIR/must_use_candidates.rs:53:1
|
||||
|
|
||||
LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:60:1
|
||||
--> $DIR/must_use_candidates.rs:65:1
|
||||
|
|
||||
LL | pub fn rcd(_x: Rc<u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc<u32>) -> bool`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:68:1
|
||||
--> $DIR/must_use_candidates.rs:73:1
|
||||
|
|
||||
LL | pub fn arcd(_x: Arc<u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc<u32>) -> bool`
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![allow(unused, clippy::needless_lifetimes)]
|
||||
#![allow(unused, clippy::needless_lifetimes, clippy::needless_pass_by_ref_mut)]
|
||||
#![warn(clippy::mut_from_ref)]
|
||||
|
||||
struct Foo;
|
||||
|
@ -12,6 +12,14 @@ error: mutable key type
|
||||
LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/mut_key.rs:30:32
|
||||
|
|
||||
LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&HashMap<Key, usize>`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: mutable key type
|
||||
--> $DIR/mut_key.rs:31:5
|
||||
|
|
||||
@ -102,5 +110,5 @@ error: mutable key type
|
||||
LL | let _map = HashMap::<Arc<Cell<usize>>, usize>::new();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
//@aux-build:proc_macros.rs:proc-macro
|
||||
#![warn(clippy::mut_mut)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::no_effect, clippy::uninlined_format_args, clippy::unnecessary_operation)]
|
||||
#![allow(
|
||||
clippy::no_effect,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::unnecessary_operation,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::{external, inline_macros};
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:9:11
|
||||
--> $DIR/mut_mut.rs:14:11
|
||||
|
|
||||
LL | fn fun(x: &mut &mut u32) -> bool {
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -7,13 +7,13 @@ LL | fn fun(x: &mut &mut u32) -> bool {
|
||||
= note: `-D clippy::mut-mut` implied by `-D warnings`
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:26:17
|
||||
--> $DIR/mut_mut.rs:31:17
|
||||
|
|
||||
LL | let mut x = &mut &mut 1u32;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:41:25
|
||||
--> $DIR/mut_mut.rs:46:25
|
||||
|
|
||||
LL | let mut z = inline!(&mut $(&mut 3u32));
|
||||
| ^
|
||||
@ -21,37 +21,37 @@ LL | let mut z = inline!(&mut $(&mut 3u32));
|
||||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: this expression mutably borrows a mutable reference. Consider reborrowing
|
||||
--> $DIR/mut_mut.rs:28:21
|
||||
--> $DIR/mut_mut.rs:33:21
|
||||
|
|
||||
LL | let mut y = &mut x;
|
||||
| ^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:32:32
|
||||
--> $DIR/mut_mut.rs:37:32
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:32:16
|
||||
--> $DIR/mut_mut.rs:37:16
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:37:37
|
||||
--> $DIR/mut_mut.rs:42:37
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:37:16
|
||||
--> $DIR/mut_mut.rs:42:16
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> $DIR/mut_mut.rs:37:21
|
||||
--> $DIR/mut_mut.rs:42:21
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -1,3 +1,17 @@
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/mut_reference.rs:4:33
|
||||
|
|
||||
LL | fn takes_a_mutable_reference(a: &mut i32) {}
|
||||
| ^^^^^^^^ help: consider changing to: `&i32`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/mut_reference.rs:11:44
|
||||
|
|
||||
LL | fn takes_a_mutable_reference(&self, a: &mut i32) {}
|
||||
| ^^^^^^^^ help: consider changing to: `&i32`
|
||||
|
||||
error: the function `takes_an_immutable_reference` doesn't need a mutable reference
|
||||
--> $DIR/mut_reference.rs:17:34
|
||||
|
|
||||
@ -18,5 +32,5 @@ error: the method `takes_an_immutable_reference` doesn't need a mutable referenc
|
||||
LL | my_struct.takes_an_immutable_reference(&mut 42);
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
unused,
|
||||
clippy::many_single_char_names,
|
||||
clippy::needless_lifetimes,
|
||||
clippy::redundant_clone
|
||||
clippy::redundant_clone,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
#![warn(clippy::ptr_arg)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:13:14
|
||||
--> $DIR/ptr_arg.rs:14:14
|
||||
|
|
||||
LL | fn do_vec(x: &Vec<i64>) {
|
||||
| ^^^^^^^^^ help: change this to: `&[i64]`
|
||||
@ -7,43 +7,43 @@ LL | fn do_vec(x: &Vec<i64>) {
|
||||
= note: `-D clippy::ptr-arg` implied by `-D warnings`
|
||||
|
||||
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:17:18
|
||||
--> $DIR/ptr_arg.rs:18:18
|
||||
|
|
||||
LL | fn do_vec_mut(x: &mut Vec<i64>) {
|
||||
| ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
|
||||
|
||||
error: writing `&String` instead of `&str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:21:14
|
||||
--> $DIR/ptr_arg.rs:22:14
|
||||
|
|
||||
LL | fn do_str(x: &String) {
|
||||
| ^^^^^^^ help: change this to: `&str`
|
||||
|
||||
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:25:18
|
||||
--> $DIR/ptr_arg.rs:26:18
|
||||
|
|
||||
LL | fn do_str_mut(x: &mut String) {
|
||||
| ^^^^^^^^^^^ help: change this to: `&mut str`
|
||||
|
||||
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:29:15
|
||||
--> $DIR/ptr_arg.rs:30:15
|
||||
|
|
||||
LL | fn do_path(x: &PathBuf) {
|
||||
| ^^^^^^^^ help: change this to: `&Path`
|
||||
|
||||
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:33:19
|
||||
--> $DIR/ptr_arg.rs:34:19
|
||||
|
|
||||
LL | fn do_path_mut(x: &mut PathBuf) {
|
||||
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
|
||||
|
||||
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:41:18
|
||||
--> $DIR/ptr_arg.rs:42:18
|
||||
|
|
||||
LL | fn do_vec(x: &Vec<i64>);
|
||||
| ^^^^^^^^^ help: change this to: `&[i64]`
|
||||
|
||||
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:54:14
|
||||
--> $DIR/ptr_arg.rs:55:14
|
||||
|
|
||||
LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
|
||||
| ^^^^^^^^
|
||||
@ -60,7 +60,7 @@ LL ~ x.to_owned()
|
||||
|
|
||||
|
||||
error: writing `&String` instead of `&str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:63:18
|
||||
--> $DIR/ptr_arg.rs:64:18
|
||||
|
|
||||
LL | fn str_cloned(x: &String) -> String {
|
||||
| ^^^^^^^
|
||||
@ -76,7 +76,7 @@ LL ~ x.to_owned()
|
||||
|
|
||||
|
||||
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:71:19
|
||||
--> $DIR/ptr_arg.rs:72:19
|
||||
|
|
||||
LL | fn path_cloned(x: &PathBuf) -> PathBuf {
|
||||
| ^^^^^^^^
|
||||
@ -92,7 +92,7 @@ LL ~ x.to_path_buf()
|
||||
|
|
||||
|
||||
error: writing `&String` instead of `&str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:79:44
|
||||
--> $DIR/ptr_arg.rs:80:44
|
||||
|
|
||||
LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
|
||||
| ^^^^^^^
|
||||
@ -106,19 +106,19 @@ LL ~ let c = y;
|
||||
|
|
||||
|
||||
error: using a reference to `Cow` is not recommended
|
||||
--> $DIR/ptr_arg.rs:93:25
|
||||
--> $DIR/ptr_arg.rs:94:25
|
||||
|
|
||||
LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
|
||||
| ^^^^^^^^^^^ help: change this to: `&[i32]`
|
||||
|
||||
error: writing `&String` instead of `&str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:122:66
|
||||
--> $DIR/ptr_arg.rs:123:66
|
||||
|
|
||||
LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
|
||||
| ^^^^^^^ help: change this to: `&str`
|
||||
|
||||
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:151:21
|
||||
--> $DIR/ptr_arg.rs:152:21
|
||||
|
|
||||
LL | fn foo_vec(vec: &Vec<u8>) {
|
||||
| ^^^^^^^^
|
||||
@ -131,7 +131,7 @@ LL ~ let _ = vec.to_owned().clone();
|
||||
|
|
||||
|
||||
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:156:23
|
||||
--> $DIR/ptr_arg.rs:157:23
|
||||
|
|
||||
LL | fn foo_path(path: &PathBuf) {
|
||||
| ^^^^^^^^
|
||||
@ -144,7 +144,7 @@ LL ~ let _ = path.to_path_buf().clone();
|
||||
|
|
||||
|
||||
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:161:21
|
||||
--> $DIR/ptr_arg.rs:162:21
|
||||
|
|
||||
LL | fn foo_str(str: &PathBuf) {
|
||||
| ^^^^^^^^
|
||||
@ -157,43 +157,43 @@ LL ~ let _ = str.to_path_buf().clone();
|
||||
|
|
||||
|
||||
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:167:29
|
||||
--> $DIR/ptr_arg.rs:168:29
|
||||
|
|
||||
LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
|
||||
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
|
||||
|
||||
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:229:17
|
||||
--> $DIR/ptr_arg.rs:230:17
|
||||
|
|
||||
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
|
||||
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
|
||||
|
||||
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:229:35
|
||||
--> $DIR/ptr_arg.rs:230:35
|
||||
|
|
||||
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
|
||||
| ^^^^^^^^^^^ help: change this to: `&mut str`
|
||||
|
||||
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
|
||||
--> $DIR/ptr_arg.rs:229:51
|
||||
--> $DIR/ptr_arg.rs:230:51
|
||||
|
|
||||
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
|
||||
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
|
||||
|
||||
error: using a reference to `Cow` is not recommended
|
||||
--> $DIR/ptr_arg.rs:252:39
|
||||
--> $DIR/ptr_arg.rs:253:39
|
||||
|
|
||||
LL | fn cow_elided_lifetime<'a>(input: &'a Cow<str>) -> &'a str {
|
||||
| ^^^^^^^^^^^^ help: change this to: `&str`
|
||||
|
||||
error: using a reference to `Cow` is not recommended
|
||||
--> $DIR/ptr_arg.rs:257:36
|
||||
--> $DIR/ptr_arg.rs:258:36
|
||||
|
|
||||
LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`
|
||||
|
||||
error: using a reference to `Cow` is not recommended
|
||||
--> $DIR/ptr_arg.rs:260:40
|
||||
--> $DIR/ptr_arg.rs:261:40
|
||||
|
|
||||
LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
|
||||
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![warn(clippy::read_zero_byte_vec)]
|
||||
#![allow(clippy::unused_io_amount)]
|
||||
#![allow(clippy::unused_io_amount, clippy::needless_pass_by_ref_mut)]
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![warn(clippy::self_assignment)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![allow(clippy::useless_vec, clippy::needless_pass_by_ref_mut)]
|
||||
|
||||
pub struct S<'a> {
|
||||
a: i32,
|
||||
|
@ -39,6 +39,14 @@ LL | | }
|
||||
|
|
||||
= help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name
|
||||
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/method_list_2.rs:38:31
|
||||
|
|
||||
LL | pub fn hash(&self, state: &mut T) {
|
||||
| ^^^^^^ help: consider changing to: `&T`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: method `index` can be confused for the standard trait method `std::ops::Index::index`
|
||||
--> $DIR/method_list_2.rs:42:5
|
||||
|
|
||||
@ -149,5 +157,5 @@ LL | | }
|
||||
|
|
||||
= help: consider implementing the trait `std::ops::Sub` or choosing a less ambiguous method name
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
|
@ -72,5 +72,13 @@ LL | vec1 = Vec::with_capacity(10);
|
||||
LL | vec1.resize(10, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: this argument is a mutable reference, but not used mutably
|
||||
--> $DIR/slow_vector_initialization.rs:62:18
|
||||
|
|
||||
LL | fn do_stuff(vec: &mut [u8]) {}
|
||||
| ^^^^^^^^^ help: consider changing to: `&[u8]`
|
||||
|
|
||||
= note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
clippy::disallowed_names,
|
||||
clippy::needless_lifetimes,
|
||||
clippy::redundant_field_names,
|
||||
clippy::uninlined_format_args
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
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:51:11
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:52:11
|
||||
|
|
||||
LL | fn bad(x: &u32, y: &Foo, z: &Baz) {}
|
||||
| ^^^^ help: consider passing by value instead: `u32`
|
||||
@ -11,103 +11,103 @@ 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:51:20
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:52: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:51:29
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:52: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:58:12
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:59: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:58:22
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:59: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:58:31
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:59: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:58:40
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:59: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:60:16
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:61: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:60:25
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:61: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:60:34
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:61: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:62:35
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:63:35
|
||||
|
|
||||
LL | fn bad_issue7518(self, other: &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)
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:74:16
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:75: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:74:25
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:75: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:74:34
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:75: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:78:34
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:79: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:110:21
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:111:21
|
||||
|
|
||||
LL | fn foo_never(x: &i32) {
|
||||
| ^^^^ help: consider passing by value instead: `i32`
|
||||
|
||||
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:115:15
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:116:15
|
||||
|
|
||||
LL | fn foo(x: &i32) {
|
||||
| ^^^^ help: consider passing by value instead: `i32`
|
||||
|
||||
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:142:37
|
||||
--> $DIR/trivially_copy_pass_by_ref.rs:143:37
|
||||
|
|
||||
LL | fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 {
|
||||
| ^^^^^^^ help: consider passing by value instead: `u32`
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, clippy::needless_pass_by_ref_mut)]
|
||||
#![warn(clippy::unused_io_amount)]
|
||||
|
||||
extern crate futures;
|
||||
|
@ -1,6 +1,10 @@
|
||||
//@run-rustfix
|
||||
#![deny(clippy::useless_asref)]
|
||||
#![allow(clippy::explicit_auto_deref, clippy::uninlined_format_args)]
|
||||
#![allow(
|
||||
clippy::explicit_auto_deref,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
//@run-rustfix
|
||||
#![deny(clippy::useless_asref)]
|
||||
#![allow(clippy::explicit_auto_deref, clippy::uninlined_format_args)]
|
||||
#![allow(
|
||||
clippy::explicit_auto_deref,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:43:18
|
||||
--> $DIR/useless_asref.rs:47: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:45:20
|
||||
--> $DIR/useless_asref.rs:49:20
|
||||
|
|
||||
LL | foo_rslice(rslice.as_ref());
|
||||
| ^^^^^^^^^^^^^^^ help: try this: `rslice`
|
||||
|
||||
error: this call to `as_mut` does nothing
|
||||
--> $DIR/useless_asref.rs:49:21
|
||||
--> $DIR/useless_asref.rs:53:21
|
||||
|
|
||||
LL | foo_mrslice(mrslice.as_mut());
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:51:20
|
||||
--> $DIR/useless_asref.rs:55:20
|
||||
|
|
||||
LL | foo_rslice(mrslice.as_ref());
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `mrslice`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:58:20
|
||||
--> $DIR/useless_asref.rs:62:20
|
||||
|
|
||||
LL | foo_rslice(rrrrrslice.as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:60:18
|
||||
--> $DIR/useless_asref.rs:64:18
|
||||
|
|
||||
LL | foo_rstr(rrrrrstr.as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr`
|
||||
|
||||
error: this call to `as_mut` does nothing
|
||||
--> $DIR/useless_asref.rs:65:21
|
||||
--> $DIR/useless_asref.rs:69:21
|
||||
|
|
||||
LL | foo_mrslice(mrrrrrslice.as_mut());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:67:20
|
||||
--> $DIR/useless_asref.rs:71:20
|
||||
|
|
||||
LL | foo_rslice(mrrrrrslice.as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:71:16
|
||||
--> $DIR/useless_asref.rs:75:16
|
||||
|
|
||||
LL | foo_rrrrmr((&&&&MoreRef).as_ref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)`
|
||||
|
||||
error: this call to `as_mut` does nothing
|
||||
--> $DIR/useless_asref.rs:121:13
|
||||
--> $DIR/useless_asref.rs:125:13
|
||||
|
|
||||
LL | foo_mrt(mrt.as_mut());
|
||||
| ^^^^^^^^^^^^ help: try this: `mrt`
|
||||
|
||||
error: this call to `as_ref` does nothing
|
||||
--> $DIR/useless_asref.rs:123:12
|
||||
--> $DIR/useless_asref.rs:127:12
|
||||
|
|
||||
LL | foo_rt(mrt.as_ref());
|
||||
| ^^^^^^^^^^^^ help: try this: `mrt`
|
||||
|
Loading…
Reference in New Issue
Block a user