From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/noncopyable-class.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/ui/noncopyable-class.rs (limited to 'tests/ui/noncopyable-class.rs') diff --git a/tests/ui/noncopyable-class.rs b/tests/ui/noncopyable-class.rs new file mode 100644 index 000000000..11b6eb736 --- /dev/null +++ b/tests/ui/noncopyable-class.rs @@ -0,0 +1,36 @@ +// Test that a class with a non-copyable field can't be +// copied + +#[derive(Debug)] +struct Bar { + x: isize, +} + +impl Drop for Bar { + fn drop(&mut self) {} +} + +fn bar(x:isize) -> Bar { + Bar { + x: x + } +} + +#[derive(Debug)] +struct Foo { + i: isize, + j: Bar, +} + +fn foo(i:isize) -> Foo { + Foo { + i: i, + j: bar(5) + } +} + +fn main() { + let x = foo(10); + let _y = x.clone(); //~ ERROR no method named `clone` found + println!("{:?}", x); +} -- cgit v1.2.3