@@ -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
E0162 : r##"
116
163
An if-let pattern attempts to match the pattern, and enters the body if the
117
164
match was succesful. If the match is irrefutable (when it cannot fail to match),
@@ -232,7 +279,6 @@ See also https://github.com/rust-lang/rust/issues/14587
232
279
}
233
280
234
281
register_diagnostics ! {
235
- E0009 ,
236
282
E0010 ,
237
283
E0011 ,
238
284
E0012 ,
0 commit comments