@@ -114,6 +114,54 @@ reference when using guards or refactor the entire expression, perhaps by
114
114
putting the condition inside the body of the arm.
115
115
"## ,
116
116
117
+ E0009 : r##"
118
+ In a pattern, all values that don't implement the `Copy` trait have to be bound
119
+ the same way. The goal here is to avoid binding simultaneously by-move and
120
+ by-ref.
121
+
122
+ This limitation may be removed in a future version of Rust.
123
+
124
+ Wrong example:
125
+
126
+ ```
127
+ struct X { x: (), }
128
+
129
+ let x = Some((X { x: () }, X { x: () }));
130
+ match x {
131
+ Some((y, ref z)) => {},
132
+ None => panic!()
133
+ }
134
+ ```
135
+
136
+ You have two solutions:
137
+ 1. Bind the pattern's values the same way:
138
+
139
+ ```
140
+ struct X { x: (), }
141
+
142
+ let x = Some((X { x: () }, X { x: () }));
143
+ match x {
144
+ Some((ref y, ref z)) => {},
145
+ // or Some((y, z)) => {}
146
+ None => panic!()
147
+ }
148
+ ```
149
+
150
+ 2. Implement the `Copy` trait for the X structure (however, please
151
+ keep in mind that the first solution should be preferred!):
152
+
153
+ ```
154
+ #[derive(Clone, Copy)]
155
+ struct X { x: (), }
156
+
157
+ let x = Some((X { x: () }, X { x: () }));
158
+ match x {
159
+ Some((y, ref z)) => {},
160
+ None => panic!()
161
+ }
162
+ ```
163
+ "## ,
164
+
117
165
E0015 : r##"
118
166
The only function calls allowed in static or constant expressions are enum
119
167
variant constructors or struct constructors (for unit or tuple structs). This
@@ -343,7 +391,6 @@ a compile-time constant.
343
391
}
344
392
345
393
register_diagnostics ! {
346
- E0009 ,
347
394
E0010 ,
348
395
E0011 ,
349
396
E0012 ,
0 commit comments