Skip to content

Commit 6a8718c

Browse files
committed
Add test for issue 34834
1 parent 53d4476 commit 6a8718c

File tree

1 file changed

+30
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)