about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/traits/associated_type_bound/hrtb-associated.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/traits/associated_type_bound/hrtb-associated.rs b/tests/ui/traits/associated_type_bound/hrtb-associated.rs
new file mode 100644
index 00000000000..59e5a09c0cb
--- /dev/null
+++ b/tests/ui/traits/associated_type_bound/hrtb-associated.rs
@@ -0,0 +1,30 @@
+//@ check-pass
+//! This test ensures that HRTB (higher-ranked trait bounds) on associated types
+//! compile correctly. This was previously rejected by the compiler.
+//! Related issue: <https://github.com/rust-lang/rust/issues/34834>
+
+pub trait Provides<'a> {
+    type Item;
+}
+
+pub trait Selector: for<'a> Provides<'a> {
+    type Namespace: PartialEq + for<'a> PartialEq<<Self as Provides<'a>>::Item>;
+
+    fn get_namespace(&self) -> <Self as Provides>::Item;
+}
+
+pub struct MySelector;
+
+impl<'a> Provides<'a> for MySelector {
+    type Item = &'a str;
+}
+
+impl Selector for MySelector {
+    type Namespace = String;
+
+    fn get_namespace(&self) -> &str {
+        unimplemented!()
+    }
+}
+
+fn main() {}