From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/borrowck/borrowck-match-already-borrowed.rs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/ui/borrowck/borrowck-match-already-borrowed.rs (limited to 'tests/ui/borrowck/borrowck-match-already-borrowed.rs') diff --git a/tests/ui/borrowck/borrowck-match-already-borrowed.rs b/tests/ui/borrowck/borrowck-match-already-borrowed.rs new file mode 100644 index 000000000..a925cbbf5 --- /dev/null +++ b/tests/ui/borrowck/borrowck-match-already-borrowed.rs @@ -0,0 +1,26 @@ +enum Foo { + A(i32), + B +} + +fn match_enum() { + let mut foo = Foo::B; + let p = &mut foo; + let _ = match foo { //~ ERROR [E0503] + Foo::B => 1, + _ => 2, + Foo::A(x) => x //~ ERROR [E0503] + }; + drop(p); +} + + +fn main() { + let mut x = 1; + let r = &mut x; + let _ = match x { + x => x + 1, //~ ERROR [E0503] + y => y + 2, //~ ERROR [E0503] + }; + drop(r); +} -- cgit v1.2.3