File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,6 @@ fn foo(x: Empty) {
6262However, this won't:
6363
6464```compile_fail
65- enum Empty {}
66-
6765fn foo(x: Option<String>) {
6866 match x {
6967 // empty
@@ -191,7 +189,7 @@ inner `String` to be moved into a variable called `s`.
191189let x = Some("s".to_string());
192190
193191match x {
194- op_string @ Some(s) => {},
192+ op_string @ Some(s) => {}, // error: cannot bind by-move with sub-bindings
195193 None => {},
196194}
197195```
@@ -288,7 +286,8 @@ struct X { x: (), }
288286
289287let x = Some((X { x: () }, X { x: () }));
290288match x {
291- Some((y, ref z)) => {},
289+ Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the
290+ // same pattern
292291 None => panic!()
293292}
294293```
@@ -574,6 +573,12 @@ be a compile-time constant. Erroneous code example:
574573 let x = [0i32; len]; // error: expected constant integer for repeat count,
575574 // found variable
576575```
576+
577+ Working example:
578+
579+ ```
580+ let x = [0i32; 10];
581+ ```
577582"## ,
578583
579584}
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ Matching with the wrong number of fields has no sensible interpretation:
4545
4646```compile_fail
4747enum Fruit {
48- Apple(String, String),
49- Pear(u32),
48+ Fruit:: Apple(String, String),
49+ Fruit:: Pear(u32),
5050}
5151
5252let x = Fruit::Apple(String::new(), String::new());
@@ -77,8 +77,8 @@ enum Number {
7777
7878// Assuming x is a Number we can pattern match on its contents.
7979match x {
80- Zero(inside) => {},
81- One(inside) => {},
80+ Number:: Zero(inside) => {},
81+ Number:: One(inside) => {},
8282}
8383```
8484
You can’t perform that action at this time.
0 commit comments