From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/nll/issue-57265-return-type-wf-check.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/ui/nll/issue-57265-return-type-wf-check.rs (limited to 'tests/ui/nll/issue-57265-return-type-wf-check.rs') diff --git a/tests/ui/nll/issue-57265-return-type-wf-check.rs b/tests/ui/nll/issue-57265-return-type-wf-check.rs new file mode 100644 index 000000000..8fb8351ce --- /dev/null +++ b/tests/ui/nll/issue-57265-return-type-wf-check.rs @@ -0,0 +1,24 @@ +use std::any::Any; + +#[derive(Debug, Clone)] +struct S(T); + +// S<&'a T> is in the return type, so we get an implied bound +// &'a T: 'static +fn foo<'a, T>(x: &'a T) -> (S<&'a T>, Box) { + let y = S(x); + + let z = Box::new(y.clone()) as Box; + (y, z) +} + +fn main() { + let x = 5; + + // Check that we require that the argument is of type `&'static String`, + // so that the return type is well-formed. + let (_, z) = foo(&"hello".to_string()); + //~^ ERROR temporary value dropped while borrowed + + println!("{:?}", z.downcast_ref::>()); +} -- cgit v1.2.3