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) {}
63 impl AsRef<u32> for Foo {
64 fn as_ref(&self) -> &u32 {
70 fn good(&self, a: &mut u32, b: u32, c: &Bar) {}
72 fn bad2(x: &u32, y: &Foo, z: &Baz) {}
76 fn trait_method(&self, _foo: &Foo);
80 fn trait_method2(&self, _color: &Color);
83 impl MyTrait for Foo {
84 fn trait_method(&self, _foo: &Foo) {
89 #[allow(unused_variables)]
92 #[allow(clippy::trivially_copy_pass_by_ref)]
96 #[allow(clippy::trivially_copy_pass_by_ref)]
101 // Don't lint here as it is always inlined
103 fn foo_always(x: &i32) {
108 fn foo_never(x: &i32) {
119 let (mut foo, bar) = (Foo(0), Bar([0; 24]));
120 let (mut a, b, c, x, y, z) = (0, 0, Bar([0; 24]), 0, Foo(0), 0);
122 good_return_implicit_lt_ref(&y);
123 good_return_explicit_lt_ref(&y);
125 foo.good(&mut a, b, &c);
128 Foo::bad2(&x, &y, &z);
129 bar.good(&mut a, b, &c);
130 Bar::bad2(&x, &y, &z);