File tree 1 file changed +34
-1
lines changed
1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,40 @@ 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 binded the same way
117
+ than the others. The goal here is to avoid to bind by-move and by-ref at the same time.
118
+ Wrong example:
119
+ struct X { x: (), }
120
+
121
+ let x = Some((X { x: () }, X { x: () }));
122
+ match x {
123
+ Some((_y, ref _z)) => {},
124
+ None => panic!()
125
+ }
126
+
127
+ You have two solutions:
128
+ * implement the Copy trait on the X structure:
129
+ #[derive(Clone, Copy)]
130
+ struct X { x: (), }
131
+
132
+ let x = Some((X { x: () }, X { x: () }));
133
+ match x {
134
+ Some((_y, ref _z)) => {},
135
+ None => panic!()
136
+ }
137
+
138
+ * bind the the pattern's values the same way:
139
+ struct X { x: (), }
140
+
141
+ let x = Some((X { x: () }, X { x: () }));
142
+ match x {
143
+ Some((ref _y, ref _z)) => {},
144
+ // or Some((_y, _z)) => {}
145
+ None => panic!()
146
+ }
147
+ "## ,
148
+
115
149
E0162 : r##"
116
150
An if-let pattern attempts to match the pattern, and enters the body if the
117
151
match was succesful. If the match is irrefutable (when it cannot fail to match),
@@ -232,7 +266,6 @@ See also https://github.com/rust-lang/rust/issues/14587
232
266
}
233
267
234
268
register_diagnostics ! {
235
- E0009 ,
236
269
E0010 ,
237
270
E0011 ,
238
271
E0012 ,
You can’t perform that action at this time.
0 commit comments