]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/large_types_passed_by_value.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / large_types_passed_by_value.rs
CommitLineData
f20569fa
XL
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
6pub struct Large([u8; 2048]);
7
8#[derive(Clone, Copy)]
9pub struct LargeAndCopy([u8; 2048]);
10
11pub struct Small([u8; 4]);
12
13#[derive(Clone, Copy)]
14pub struct SmallAndCopy([u8; 4]);
15
16fn small(a: Small, b: SmallAndCopy) {}
17fn not_copy(a: Large) {}
18fn by_ref(a: &Large, b: &LargeAndCopy) {}
19fn mutable(mut a: LargeAndCopy) {}
20fn bad(a: LargeAndCopy) {}
21pub fn bad_but_pub(a: LargeAndCopy) {}
22
23impl 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
30trait 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
36pub trait PubLargeTypeDevourer {
37 fn devoure_array_in_public(&self, array: [u8; 6666]);
38}
39
04454e1e 40struct S;
f20569fa
XL
41impl 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)]
54fn foo_always(x: LargeAndCopy) {
55 todo!();
56}
57#[inline(never)]
58fn foo_never(x: LargeAndCopy) {
59 todo!();
60}
61#[inline]
62fn foo(x: LargeAndCopy) {
63 todo!();
64}
65
66fn main() {}