Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/ui/traits/associated_type_bound/hrtb-associated.rs
Original file line number Diff line number Diff line change
@@ -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() {}