Add test for issue 34834
This commit is contained in:
parent
53d4476111
commit
6a8718cab7
1 changed files with 30 additions and 0 deletions
30
tests/ui/traits/associated_type_bound/hrtb-associated.rs
Normal file
30
tests/ui/traits/associated_type_bound/hrtb-associated.rs
Normal 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() {}
|
Loading…
Add table
Add a link
Reference in a new issue