about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwhtahy <whtahy@users.noreply.github.com>2023-04-18 00:29:01 -0400
committerwhtahy <whtahy@users.noreply.github.com>2023-04-22 00:47:07 -0400
commitadb5ded7a71911f66e20dd3a85dd39fb236c476d (patch)
tree139e238e0e14528c89a5c91ba1df4c67ec114c8f
parent80a2ec49a4ffb7a351c41c8db14711297324b587 (diff)
downloadrust-adb5ded7a71911f66e20dd3a85dd39fb236c476d.tar.gz
rust-adb5ded7a71911f66e20dd3a85dd39fb236c476d.zip
add known-bug test for unsound issue 25860
-rw-r--r--tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs b/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs
new file mode 100644
index 00000000000..1f5562497c1
--- /dev/null
+++ b/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs
@@ -0,0 +1,16 @@
+// check-pass
+// known-bug: #25860
+
+// Should fail. The combination of variance and implied bounds for nested
+// references allows us to infer a longer lifetime than we can prove.
+
+static UNIT: &'static &'static () = &&();
+
+fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v }
+
+fn bad<'a, T>(x: &'a T) -> &'static T {
+    let f: fn(_, &'a T) -> &'static T = foo;
+    f(UNIT, x)
+}
+
+fn main() {}