]> git.lizzy.rs Git - rust.git/blob - tests/ui/large_types_passed_by_value.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / large_types_passed_by_value.rs
1 // normalize-stderr-test "\(\d+ byte\)" -> "(N byte)"
2 // normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
3
4 #![warn(clippy::large_types_passed_by_value)]
5
6 pub struct Large([u8; 2048]);
7
8 #[derive(Clone, Copy)]
9 pub struct LargeAndCopy([u8; 2048]);
10
11 pub struct Small([u8; 4]);
12
13 #[derive(Clone, Copy)]
14 pub struct SmallAndCopy([u8; 4]);
15
16 fn small(a: Small, b: SmallAndCopy) {}
17 fn not_copy(a: Large) {}
18 fn by_ref(a: &Large, b: &LargeAndCopy) {}
19 fn mutable(mut a: LargeAndCopy) {}
20 fn bad(a: LargeAndCopy) {}
21 pub fn bad_but_pub(a: LargeAndCopy) {}
22
23 impl LargeAndCopy {
24     fn self_is_ok(self) {}
25     fn other_is_not_ok(self, other: LargeAndCopy) {}
26     fn unless_other_can_change(self, mut other: LargeAndCopy) {}
27     pub fn or_were_in_public(self, other: LargeAndCopy) {}
28 }
29
30 trait LargeTypeDevourer {
31     fn devoure_array(&self, array: [u8; 6666]);
32     fn devoure_tuple(&self, tup: (LargeAndCopy, LargeAndCopy));
33     fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy));
34 }
35
36 pub trait PubLargeTypeDevourer {
37     fn devoure_array_in_public(&self, array: [u8; 6666]);
38 }
39
40 struct S {}
41 impl LargeTypeDevourer for S {
42     fn devoure_array(&self, array: [u8; 6666]) {
43         todo!();
44     }
45     fn devoure_tuple(&self, tup: (LargeAndCopy, LargeAndCopy)) {
46         todo!();
47     }
48     fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)) {
49         todo!();
50     }
51 }
52
53 #[inline(always)]
54 fn foo_always(x: LargeAndCopy) {
55     todo!();
56 }
57 #[inline(never)]
58 fn foo_never(x: LargeAndCopy) {
59     todo!();
60 }
61 #[inline]
62 fn foo(x: LargeAndCopy) {
63     todo!();
64 }
65
66 fn main() {}