about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwhtahy <whtahy@users.noreply.github.com>2023-04-18 23:11:43 -0400
committerwhtahy <whtahy@users.noreply.github.com>2023-04-22 00:47:07 -0400
commitfbfb620de8afdabddfa819e698cdbfc7a7b10797 (patch)
treee0fff8118e9b2bb633f76f820b02a97da2776586
parent232d685e6149227abb28c8fef05b00c4f50bbd28 (diff)
downloadrust-fbfb620de8afdabddfa819e698cdbfc7a7b10797.tar.gz
rust-fbfb620de8afdabddfa819e698cdbfc7a7b10797.zip
add known-bug test for unsound issue 84366
-rw-r--r--tests/ui/closures/static-closures-with-nonstatic-return.rs15
1 files changed, 15 insertions, 0 deletions
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: 'static>(_: T) {}
+
+fn main() {}