Skip to content

Commit 1a77ca3

Browse files
author
Cameron Zwarich
committed
Add another rejected example.
1 parent d017285 commit 1a77ca3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

0000-pattern-guards-with-bind-by-move.md

+15
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ fn foo(n: int) {
103103
}
104104
```
105105

106+
This example would also be rejected, even though there is no use of the
107+
move-bound variable in the first arm's expression, since the move into the bound
108+
variable would be moving the same value a second time:
109+
110+
```rust
111+
enum VecWrapper { A(Vec<int>) }
112+
113+
fn foo(x: VecWrapper) -> uint {
114+
match x {
115+
A(v) if { drop(v); false } => 1,
116+
A(v) => v.len()
117+
}
118+
}
119+
```
120+
106121
There are issues with mutation of the bound values, but that is true without
107122
the changes proposed by this RFC, e.g.
108123
[Rust issue #14684](https://github.com/mozilla/rust/issues/14684). The general

0 commit comments

Comments
 (0)