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)]
5 #![allow(clippy::blacklisted_name, clippy::redundant_field_names)]
10 #[derive(Copy, Clone)]
13 #[derive(Copy, Clone)]
27 fn good(a: &mut u32, b: u32, c: &Bar) {}
29 fn good_return_implicit_lt_ref(foo: &Foo) -> &u32 {
33 #[allow(clippy::needless_lifetimes)]
34 fn good_return_explicit_lt_ref<'a>(foo: &'a Foo) -> &'a u32 {
38 fn good_return_implicit_lt_struct(foo: &Foo) -> FooRef {
42 #[allow(clippy::needless_lifetimes)]
43 fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> {
47 fn bad(x: &u32, y: &Foo, z: &Baz) {}
50 fn good(self, a: &mut u32, b: u32, c: &Bar) {}
52 fn good2(&mut self) {}
54 fn bad(&self, x: &u32, y: &Foo, z: &Baz) {}
56 fn bad2(x: &u32, y: &Foo, z: &Baz) {}
58 fn bad_issue7518(self, other: &Self) {}
61 impl AsRef<u32> for Foo {
62 fn as_ref(&self) -> &u32 {
68 fn good(&self, a: &mut u32, b: u32, c: &Bar) {}
70 fn bad2(x: &u32, y: &Foo, z: &Baz) {}
74 fn trait_method(&self, _foo: &Foo);
78 fn trait_method2(&self, _color: &Color);
81 impl MyTrait for Foo {
82 fn trait_method(&self, _foo: &Foo) {
87 #[allow(unused_variables)]
90 #[allow(clippy::trivially_copy_pass_by_ref)]
94 #[allow(clippy::trivially_copy_pass_by_ref)]
99 // Don't lint here as it is always inlined
101 fn foo_always(x: &i32) {
106 fn foo_never(x: &i32) {
117 let (mut foo, bar) = (Foo(0), Bar([0; 24]));
118 let (mut a, b, c, x, y, z) = (0, 0, Bar([0; 24]), 0, Foo(0), 0);
120 good_return_implicit_lt_ref(&y);
121 good_return_explicit_lt_ref(&y);
123 foo.good(&mut a, b, &c);
126 Foo::bad2(&x, &y, &z);
127 bar.good(&mut a, b, &c);
128 Bar::bad2(&x, &y, &z);