summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs')
-rw-r--r--tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
new file mode 100644
index 000000000..ba04fd93a
--- /dev/null
+++ b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
@@ -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)
+}