about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwhtahy <whtahy@users.noreply.github.com>2023-04-22 13:41:53 -0400
committerwhtahy <whtahy@users.noreply.github.com>2023-04-22 13:41:53 -0400
commit6f6550f156eb6ea18e90db1712b30460613ad4a8 (patch)
tree7e27ebd3b83675393dcba6e7a45f874f9a7a36f4
parentcff6c0e0c8d33efe4b64b08751008ac353c9b232 (diff)
downloadrust-6f6550f156eb6ea18e90db1712b30460613ad4a8.tar.gz
rust-6f6550f156eb6ea18e90db1712b30460613ad4a8.zip
add known-bug test for unsound issue 100051
-rw-r--r--tests/ui/fn/implied-bounds-impl-header-projections.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/fn/implied-bounds-impl-header-projections.rs b/tests/ui/fn/implied-bounds-impl-header-projections.rs
new file mode 100644
index 00000000000..28cec805032
--- /dev/null
+++ b/tests/ui/fn/implied-bounds-impl-header-projections.rs
@@ -0,0 +1,31 @@
+// check-pass
+// known-bug: #100051
+
+// Should fail. Implied bounds from projections in impl headers can create
+// improper lifetimes.  Variant of issue #98543 which was fixed by #99217.
+
+trait Trait {
+    type Type;
+}
+
+impl<T> Trait for T {
+    type Type = ();
+}
+
+trait Extend<'a, 'b> {
+    fn extend(self, s: &'a str) -> &'b str;
+}
+
+impl<'a, 'b> Extend<'a, 'b> for <&'b &'a () as Trait>::Type
+where
+    for<'what, 'ever> &'what &'ever (): Trait,
+{
+    fn extend(self, s: &'a str) -> &'b str {
+        s
+    }
+}
+
+fn main() {
+    let y = <() as Extend<'_, '_>>::extend((), &String::from("Hello World"));
+    println!("{}", y);
+}