File tree 1 file changed +30
-0
lines changed
tests/ui/traits/associated_type_bound
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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 ( ) { }
You can’t perform that action at this time.
0 commit comments