diff options
| author | reddevilmidzy <midzy0228@gmail.com> | 2025-04-14 11:06:46 +0900 |
|---|---|---|
| committer | reddevilmidzy <midzy0228@gmail.com> | 2025-04-14 17:16:23 +0900 |
| commit | 6a8718cab772ecfbce3de7a701e9abf8e476bc37 (patch) | |
| tree | 0829b47b588b42215f03e9a130c0c7598e96976e | |
| parent | 53d44761118e60a6c0b9a789faa4477505f0190b (diff) | |
| download | rust-6a8718cab772ecfbce3de7a701e9abf8e476bc37.tar.gz rust-6a8718cab772ecfbce3de7a701e9abf8e476bc37.zip | |
Add test for issue 34834
| -rw-r--r-- | tests/ui/traits/associated_type_bound/hrtb-associated.rs | 30 |
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() {} |
