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 --- .../lifetimes/lifetime-doesnt-live-long-enough.rs | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/ui/lifetimes/lifetime-doesnt-live-long-enough.rs (limited to 'tests/ui/lifetimes/lifetime-doesnt-live-long-enough.rs') diff --git a/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.rs b/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.rs new file mode 100644 index 000000000..d2b782c92 --- /dev/null +++ b/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.rs @@ -0,0 +1,49 @@ +trait ListItem<'a> { + fn list_name() -> &'a str; +} + +trait Collection { fn len(&self) -> usize; } + +// is now well formed. RFC 2093 +struct List<'a, T: ListItem<'a>> { + slice: &'a [T] +} + +impl<'a, T: ListItem<'a>> Collection for List<'a, T> { + fn len(&self) -> usize { + 0 + } +} + +struct Foo { + foo: &'static T + //~^ ERROR may not live long enough +} + +trait X: Sized { + fn foo<'a, L: X<&'a Nested>>(); + //~^ ERROR may not live long enough + + // check that we give a sane error for `Self` + fn bar<'a, L: X<&'a Nested>>(); + //~^ ERROR may not live long enough + + // check that we give a sane error for nested generics + fn baz<'a, L, M: X<&'a Nested>>() { + //~^ ERROR may not live long enough + } +} + +trait TraitB {} + +struct Nested(K); +impl Nested { + fn generic_in_parent<'a, L: X<&'a Nested>>() { + //~^ ERROR may not live long enough + } + fn generic_in_child<'a, 'b, L: X<&'a Nested>, M: 'b>() { + //~^ ERROR may not live long enough + } +} + +fn main() {} -- cgit v1.2.3