File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 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
112112putting the condition inside the body of the arm.
113113"## ,
114114
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+
115149E0162 : r##"
116150An if-let pattern attempts to match the pattern, and enters the body if the
117151match 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
232266}
233267
234268register_diagnostics ! {
235- E0009 ,
236269 E0010 ,
237270 E0011 ,
238271 E0012 ,
You can’t perform that action at this time.
0 commit comments