1 #![feature(fn_traits, unboxed_closures)]
2 #![warn(clippy::no_effect_underscore_binding)]
3 #![allow(dead_code, path_statements)]
4 #![allow(
5 clippy::deref_addrof,
6 clippy::redundant_field_names,
7 clippy::uninlined_format_args,
8 clippy::unnecessary_struct_initialization,
9 clippy::useless_vec
10 )]
11
12 struct Unit;
13 struct Tuple(i32);
14 struct Struct {
15 field: i32,
16 }
17 enum Enum {
18 Tuple(i32),
19 Struct { field: i32 },
20 }
21 struct DropUnit;
22 impl Drop for DropUnit {
drop(&mut self)23 fn drop(&mut self) {}
24 }
25 struct DropStruct {
26 field: i32,
27 }
28 impl Drop for DropStruct {
drop(&mut self)29 fn drop(&mut self) {}
30 }
31 struct DropTuple(i32);
32 impl Drop for DropTuple {
drop(&mut self)33 fn drop(&mut self) {}
34 }
35 enum DropEnum {
36 Tuple(i32),
37 Struct { field: i32 },
38 }
39 impl Drop for DropEnum {
drop(&mut self)40 fn drop(&mut self) {}
41 }
42 struct FooString {
43 s: String,
44 }
45 union Union {
46 a: u8,
47 b: f64,
48 }
49
get_number() -> i3250 fn get_number() -> i32 {
51 0
52 }
get_struct() -> Struct53 fn get_struct() -> Struct {
54 Struct { field: 0 }
55 }
get_drop_struct() -> DropStruct56 fn get_drop_struct() -> DropStruct {
57 DropStruct { field: 0 }
58 }
59
unsafe_fn() -> i3260 unsafe fn unsafe_fn() -> i32 {
61 0
62 }
63
64 struct GreetStruct1;
65
66 impl FnOnce<(&str,)> for GreetStruct1 {
67 type Output = ();
68
call_once(self, (who,): (&str,)) -> Self::Output69 extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
70 println!("hello {}", who);
71 }
72 }
73
74 struct GreetStruct2();
75
76 impl FnOnce<(&str,)> for GreetStruct2 {
77 type Output = ();
78
call_once(self, (who,): (&str,)) -> Self::Output79 extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
80 println!("hello {}", who);
81 }
82 }
83
84 struct GreetStruct3;
85
86 impl FnOnce<(&str,)> for GreetStruct3 {
87 type Output = ();
88
call_once(self, (who,): (&str,)) -> Self::Output89 extern "rust-call" fn call_once(self, (who,): (&str,)) -> Self::Output {
90 println!("hello {}", who);
91 }
92 }
93
main()94 fn main() {
95 let s = get_struct();
96 let s2 = get_struct();
97
98 0;
99 s2;
100 Unit;
101 Tuple(0);
102 Struct { field: 0 };
103 Struct { ..s };
104 Union { a: 0 };
105 Enum::Tuple(0);
106 Enum::Struct { field: 0 };
107 5 + 6;
108 *&42;
109 &6;
110 (5, 6, 7);
111 ..;
112 5..;
113 ..5;
114 5..6;
115 5..=6;
116 [42, 55];
117 [42, 55][1];
118 (42, 55).1;
119 [42; 55];
120 [42; 55][13];
121 let mut x = 0;
122 || x += 5;
123 let s: String = "foo".into();
124 FooString { s: s };
125 let _unused = 1;
126 let _penguin = || println!("Some helpful closure");
127 let _duck = Struct { field: 0 };
128 let _cat = [2, 4, 6, 8][2];
129
130 #[allow(clippy::no_effect)]
131 0;
132
133 // Do not warn
134 get_number();
135 unsafe { unsafe_fn() };
136 let _used = get_struct();
137 let _x = vec![1];
138 DropUnit;
139 DropStruct { field: 0 };
140 DropTuple(0);
141 DropEnum::Tuple(0);
142 DropEnum::Struct { field: 0 };
143 GreetStruct1("world");
144 GreetStruct2()("world");
145 GreetStruct3 {}("world");
146 }
147