]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / traits / associated_type_bound / check-trait-object-bounds-3.rs
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
new file mode 100644 (file)
index 0000000..ba04fd9
--- /dev/null
@@ -0,0 +1,20 @@
+// Check that we validate associated type bounds for trait objects
+
+trait X<'a> {
+    type Y: Into<&'static str> + From<&'a str>;
+}
+
+fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str {
+    T::Y::from(s).into()
+}
+
+pub fn main() {
+    let z;
+    {
+        let s = String::from("abcdef");
+        z = f::<dyn X<Y = &str>>(&s);
+        //~^ ERROR `s` does not live long enough
+    }
+
+    println!("{}", z)
+}