1
1
//@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)"
2
- //@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)"
2
+ //@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: 8 byte)"
3
3
#![ deny( clippy:: trivially_copy_pass_by_ref) ]
4
4
#![ allow(
5
5
clippy:: disallowed_names,
@@ -50,17 +50,28 @@ fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> {
50
50
}
51
51
52
52
fn bad ( x : & u32 , y : & Foo , z : & Baz ) { }
53
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
54
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
55
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
53
56
54
57
impl Foo {
55
58
fn good ( self , a : & mut u32 , b : u32 , c : & Bar ) { }
56
59
57
60
fn good2 ( & mut self ) { }
58
61
59
62
fn bad ( & self , x : & u32 , y : & Foo , z : & Baz ) { }
63
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
64
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
65
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
66
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
60
67
61
68
fn bad2 ( x : & u32 , y : & Foo , z : & Baz ) { }
69
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
70
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
71
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
62
72
63
73
fn bad_issue7518 ( self , other : & Self ) { }
74
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
64
75
}
65
76
66
77
impl AsRef < u32 > for Foo {
@@ -73,10 +84,14 @@ impl Bar {
73
84
fn good ( & self , a : & mut u32 , b : u32 , c : & Bar ) { }
74
85
75
86
fn bad2 ( x : & u32 , y : & Foo , z : & Baz ) { }
87
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
88
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
89
+ //~| ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
76
90
}
77
91
78
92
trait MyTrait {
79
93
fn trait_method ( & self , _foo : & Foo ) ;
94
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
80
95
}
81
96
82
97
pub trait MyTrait2 {
@@ -109,11 +124,13 @@ mod issue5876 {
109
124
110
125
#[ inline( never) ]
111
126
fn foo_never ( x : & i32 ) {
127
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
112
128
println ! ( "{}" , x) ;
113
129
}
114
130
115
131
#[ inline]
116
132
fn foo ( x : & i32 ) {
133
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
117
134
println ! ( "{}" , x) ;
118
135
}
119
136
}
@@ -141,6 +158,7 @@ async fn _async_explicit<'a>(x: &'a u32) -> &'a u32 {
141
158
}
142
159
143
160
fn _unrelated_lifetimes < ' a , ' b > ( _x : & ' a u32 , y : & ' b u32 ) -> & ' b u32 {
161
+ //~^ ERROR: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
144
162
y
145
163
}
146
164
0 commit comments