1 // normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
2 // normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
4 #![deny(clippy::trivially_copy_pass_by_ref)]
6 clippy::many_single_char_names,
7 clippy::blacklisted_name,
8 clippy::redundant_field_names
11 #[derive(Copy, Clone)]
14 #[derive(Copy, Clone)]
17 #[derive(Copy, Clone)]
31 fn good(a: &mut u32, b: u32, c: &Bar) {}
33 fn good_return_implicit_lt_ref(foo: &Foo) -> &u32 {
37 #[allow(clippy::needless_lifetimes)]
38 fn good_return_explicit_lt_ref<'a>(foo: &'a Foo) -> &'a u32 {
42 fn good_return_implicit_lt_struct(foo: &Foo) -> FooRef {
46 #[allow(clippy::needless_lifetimes)]
47 fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> {
51 fn bad(x: &u32, y: &Foo, z: &Baz) {}
54 fn good(self, a: &mut u32, b: u32, c: &Bar) {}
56 fn good2(&mut self) {}
58 fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
60 fn bad2(x: &u32, y: &Foo, z: &Baz) {}
62 fn bad_issue7518(self, other: &Self) {}
65 impl AsRef<u32> for Foo {
66 fn as_ref(&self) -> &u32 {
72 fn good(&self, a: &mut u32, b: u32, c: &Bar) {}
74 fn bad2(x: &u32, y: &Foo, z: &Baz) {}
78 fn trait_method(&self, _foo: &Foo);
82 fn trait_method2(&self, _color: &Color);
85 impl MyTrait for Foo {
86 fn trait_method(&self, _foo: &Foo) {
91 #[allow(unused_variables)]
94 #[allow(clippy::trivially_copy_pass_by_ref)]
98 #[allow(clippy::trivially_copy_pass_by_ref)]
103 // Don't lint here as it is always inlined
105 fn foo_always(x: &i32) {
110 fn foo_never(x: &i32) {
121 let (mut foo, bar) = (Foo(0), Bar([0; 24]));
122 let (mut a, b, c, x, y, z) = (0, 0, Bar([0; 24]), 0, Foo(0), 0);
124 good_return_implicit_lt_ref(&y);
125 good_return_explicit_lt_ref(&y);
127 foo.good(&mut a, b, &c);
130 Foo::bad2(&x, &y, &z);
131 bar.good(&mut a, b, &c);
132 Bar::bad2(&x, &y, &z);