From fbfb620de8afdabddfa819e698cdbfc7a7b10797 Mon Sep 17 00:00:00 2001 From: whtahy Date: Tue, 18 Apr 2023 23:11:43 -0400 Subject: [PATCH] add known-bug test for unsound issue 84366 --- .../static-closures-with-nonstatic-return.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/ui/closures/static-closures-with-nonstatic-return.rs diff --git a/tests/ui/closures/static-closures-with-nonstatic-return.rs b/tests/ui/closures/static-closures-with-nonstatic-return.rs new file mode 100644 index 00000000000..b5f0684bae9 --- /dev/null +++ b/tests/ui/closures/static-closures-with-nonstatic-return.rs @@ -0,0 +1,15 @@ +// check-pass +// known-bug: #84366 + +// Should fail. Associated types of 'static types should be `'static`, but +// argument-free closures can be `'static` and return non-`'static` types. + +#[allow(dead_code)] +fn foo<'a>() { + let closure = || -> &'a str { "" }; + assert_static(closure); +} + +fn assert_static(_: T) {} + +fn main() {}