From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/borrowck/borrowck-move-error-with-note.rs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/test/ui/borrowck/borrowck-move-error-with-note.rs (limited to 'src/test/ui/borrowck/borrowck-move-error-with-note.rs') diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.rs b/src/test/ui/borrowck/borrowck-move-error-with-note.rs new file mode 100644 index 000000000..ef38cbb63 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.rs @@ -0,0 +1,54 @@ +enum Foo { + Foo1(Box, Box), + Foo2(Box), + Foo3, +} + + + +fn blah() { + let f = &Foo::Foo1(Box::new(1), Box::new(2)); + match *f { //~ ERROR cannot move out of + Foo::Foo1(num1, + num2) => (), + Foo::Foo2(num) => (), + Foo::Foo3 => () + } +} + +struct S { + f: String, + g: String +} +impl Drop for S { + fn drop(&mut self) { println!("{}", self.f); } +} + +fn move_in_match() { + match (S {f: "foo".to_string(), g: "bar".to_string()}) { + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait + S { + f: _s, + g: _t + } => {} + } +} + +// from issue-8064 +struct A { + a: Box, +} + +fn free(_: T) {} + +fn blah2() { + let a = &A { a: Box::new(1) }; + match a.a { //~ ERROR cannot move out of + n => { + free(n) + } + } + free(a) +} + +fn main() {} -- cgit v1.2.3