Skip to content

Commit 68c7a1f

Browse files
committed
Add test for issue 34834
1 parent 53d4476 commit 68c7a1f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ run-pass
2+
//@ edition:2018
3+
//! This test ensures that HRTB (higher-ranked trait bounds) on associated types
4+
//! compile correctly. This was previously rejected by the compiler.
5+
//! Related issue: <https://github.com/rust-lang/rust/issues/34834>
6+
7+
pub trait Provides<'a> {
8+
type Item;
9+
}
10+
11+
pub trait Selector: for<'a> Provides<'a> {
12+
type Namespace: PartialEq + for<'a> PartialEq<<Self as Provides<'a>>::Item>;
13+
14+
fn get_namespace(&self) -> <Self as Provides>::Item;
15+
}
16+
17+
pub struct MySelector;
18+
19+
impl<'a> Provides<'a> for MySelector {
20+
type Item = &'a str;
21+
}
22+
23+
impl Selector for MySelector {
24+
type Namespace = String;
25+
26+
fn get_namespace(&self) -> &str {
27+
unimplemented!()
28+
}
29+
}
30+
31+
fn main() {}

0 commit comments

Comments
 (0)