Add test for issue 34834

This commit is contained in:
reddevilmidzy 2025-04-14 11:06:46 +09:00
parent 53d4476111
commit 6a8718cab7

View file

@ -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() {}