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 --- .../object-lifetime-default-mybox.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-mybox.rs (limited to 'src/test/ui/object-lifetime/object-lifetime-default-mybox.rs') diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs new file mode 100644 index 000000000..5e6e5e2c0 --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -0,0 +1,37 @@ +// Test a "pass-through" object-lifetime-default that produces errors. + +#![allow(dead_code)] + +trait SomeTrait { + fn dummy(&self) { } +} + +struct MyBox { + r: Box +} + +fn deref(ss: &T) -> T { + // produces the type of a deref without worrying about whether a + // move out would actually be legal + loop { } +} + +fn load0(ss: &MyBox) -> MyBox { + deref(ss) +} + +fn load1<'a,'b>(a: &'a MyBox, + b: &'b MyBox) + -> &'b MyBox +{ + a + //~^ ERROR lifetime may not live long enough +} + +fn load2<'a>(ss: &MyBox) -> MyBox { + load0(ss) + //~^ ERROR borrowed data escapes outside of function +} + +fn main() { +} -- cgit v1.2.3