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