@@ -112,6 +112,53 @@ reference when using guards or refactor the entire expression, perhaps by
112
112
putting the condition inside the body of the arm.
113
113
"## ,
114
114
115
+ E0009 : r##"
116
+ In a pattern, all values that don't implement the `Copy` trait have to be bound
117
+ the same way. The goal here is to avoid binding simultaneous by-move and by-ref.
118
+
119
+ This limitation may be removed in a future version of Rust.
120
+
121
+ Wrong example:
122
+
123
+ ```
124
+ struct X { x: (), }
125
+
126
+ let x = Some((X { x: () }, X { x: () }));
127
+ match x {
128
+ Some((y, ref z)) => {},
129
+ None => panic!()
130
+ }
131
+ ```
132
+
133
+ You have two solutions:
134
+ 1. Bind the pattern's values the same way:
135
+
136
+ ```
137
+ struct X { x: (), }
138
+
139
+ let x = Some((X { x: () }, X { x: () }));
140
+ match x {
141
+ Some((ref y, ref z)) => {},
142
+ // or Some((y, z)) => {}
143
+ None => panic!()
144
+ }
145
+ ```
146
+
147
+ 2. Implement the `Copy` trait for the X structure (however, please
148
+ keep in mind that the first solution should be preferred!):
149
+
150
+ ```
151
+ #[derive(Clone, Copy)]
152
+ struct X { x: (), }
153
+
154
+ let x = Some((X { x: () }, X { x: () }));
155
+ match x {
156
+ Some((y, ref z)) => {},
157
+ None => panic!()
158
+ }
159
+ ```
160
+ "## ,
161
+
115
162
E0152 : r##"
116
163
Lang items are already implemented in the standard library. Unless you are
117
164
writing a free-standing application (e.g. a kernel), you do not need to provide
@@ -308,7 +355,6 @@ a compile-time constant.
308
355
}
309
356
310
357
register_diagnostics ! {
311
- E0009 ,
312
358
E0010 ,
313
359
E0011 ,
314
360
E0012 ,
0 commit comments