about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/wf/wf-in-where-clause-static.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/wf/wf-in-where-clause-static.rs b/tests/ui/wf/wf-in-where-clause-static.rs
new file mode 100644
index 00000000000..86722afdf9f
--- /dev/null
+++ b/tests/ui/wf/wf-in-where-clause-static.rs
@@ -0,0 +1,23 @@
+// check-pass
+// known-bug: #98117
+
+// Should fail. Functions are responsible for checking the well-formedness of
+// their own where clauses, so this should fail and require an explicit bound
+// `T: 'static`.
+
+use std::fmt::Display;
+
+trait Static: 'static {}
+impl<T> Static for &'static T {}
+
+fn foo<S: Display>(x: S) -> Box<dyn Display>
+where
+    &'static S: Static,
+{
+    Box::new(x)
+}
+
+fn main() {
+    let s = foo(&String::from("blah blah blah"));
+    println!("{}", s);
+}