diff options
| author | bors <bors@rust-lang.org> | 2020-02-09 04:01:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-09 04:01:28 +0000 |
| commit | f8d830b4decaef5a6ae0f27baac14dfb48baa4c5 (patch) | |
| tree | a5e7a6a7f68e12dbd174c1313b4d0ab0e742dbdc /src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs | |
| parent | a19edd6b161521a4f66716b3b45b8cf4d3f03f3a (diff) | |
| parent | d2b88b7050b0e21b136022c4cfe8d352c1425588 (diff) | |
| download | rust-f8d830b4decaef5a6ae0f27baac14dfb48baa4c5.tar.gz rust-f8d830b4decaef5a6ae0f27baac14dfb48baa4c5.zip | |
Auto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper
Initial implementation of `#![feature(move_ref_pattern)]` Following up on #45600, under the gate `#![feature(move_ref_pattern)]`, `(ref x, mut y)` is allowed subject to restrictions necessary for soundness. The match checking implementation and tests for `#![feature(bindings_after_at)]` is also adjusted as necessary. Closes #45600. Tracking issue: #68354. r? @matthewjasper
Diffstat (limited to 'src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs')
| -rw-r--r-- | src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs b/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs new file mode 100644 index 00000000000..fb92eb1ba32 --- /dev/null +++ b/src/test/ui/pattern/move-ref-patterns/feature-gate-move_ref_pattern.rs @@ -0,0 +1,23 @@ +fn main() { + #[derive(Clone)] + struct X { + x: (), + } + let mut tup = (X { x: () }, X { x: () }); + match Some(tup.clone()) { + Some((y, ref z)) => {} + //~^ ERROR binding by-move and by-ref in the same pattern is unstable + None => panic!(), + } + + let (ref a, b) = tup.clone(); + //~^ ERROR binding by-move and by-ref in the same pattern is unstable + + let (a, mut b) = &tup; + //~^ ERROR binding by-move and by-ref in the same pattern is unstable + //~| ERROR cannot move out of a shared reference + + let (mut a, b) = &mut tup; + //~^ ERROR binding by-move and by-ref in the same pattern is unstable + //~| ERROR cannot move out of a mutable reference +} |
