File tree 2 files changed +101
-0
lines changed
2 files changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ run-pass
2
+ //@ revisions: default feature
3
+ #![ cfg_attr( feature, feature( arbitrary_self_types) ) ]
4
+
5
+ // This test aims to be like the IndexVec within rustc, and conflicts
6
+ // over its into_iter().
7
+
8
+ #[ allow( dead_code) ]
9
+ trait Foo {
10
+ fn foo ( self ) -> usize ;
11
+ }
12
+
13
+ struct IndexVec < T > ( T ) ;
14
+
15
+ impl < T > std:: ops:: Deref for IndexVec < T > {
16
+ type Target = T ;
17
+
18
+ fn deref ( & self ) -> & Self :: Target {
19
+ & self . 0
20
+ }
21
+ }
22
+
23
+ impl < ' a , T > Foo for & ' a IndexVec < T > {
24
+ fn foo ( self ) -> usize {
25
+ 2
26
+ }
27
+ }
28
+
29
+ impl < T > IndexVec < T > {
30
+ fn foo ( self ) -> usize {
31
+ 1
32
+ }
33
+ }
34
+
35
+ fn main ( ) {
36
+ let ivec = IndexVec ( 0usize ) ;
37
+ assert_eq ! ( ivec. foo( ) , 1 ) ;
38
+ }
Original file line number Diff line number Diff line change
1
+ //@ run-pass
2
+ //@ revisions: default feature
3
+ #![ cfg_attr( feature, feature( arbitrary_self_types) ) ]
4
+
5
+ use std:: pin:: Pin ;
6
+ use std:: ops:: DerefMut ;
7
+ use std:: marker:: Unpin ;
8
+
9
+ struct TryChunks ;
10
+
11
+ impl TryChunks {
12
+ #[ allow( dead_code) ]
13
+ fn take ( self : std:: pin:: Pin < & mut Self > ) -> usize {
14
+ 1
15
+ }
16
+ }
17
+
18
+ #[ allow( dead_code) ]
19
+ trait Stream {
20
+ fn poll_next ( self : std:: pin:: Pin < & mut Self > ) ;
21
+ }
22
+
23
+ #[ allow( dead_code) ]
24
+ trait StreamExt : Stream {
25
+ #[ allow( dead_code) ]
26
+ fn take ( self ) -> usize where Self : Sized
27
+ {
28
+ 2
29
+ }
30
+ }
31
+
32
+ impl < T : ?Sized > StreamExt for T where T : Stream { }
33
+
34
+ impl Stream for TryChunks {
35
+ fn poll_next ( self : std:: pin:: Pin < & mut Self > ) {
36
+ assert_eq ! ( self . take( ) , 1 ) ;
37
+ }
38
+ }
39
+
40
+ #[ allow( dead_code) ]
41
+ impl < S : ?Sized + Stream + Unpin > Stream for & mut S {
42
+ #[ allow( dead_code) ]
43
+ fn poll_next ( mut self : Pin < & mut Self > ) {
44
+ S :: poll_next ( Pin :: new ( & mut * * self ) )
45
+ }
46
+ }
47
+
48
+ #[ allow( dead_code) ]
49
+ impl < P > Stream for Pin < P >
50
+ where
51
+ P : DerefMut + Unpin ,
52
+ P :: Target : Stream ,
53
+ {
54
+ #[ allow( dead_code) ]
55
+ fn poll_next ( self : Pin < & mut Self > ) {
56
+ self . get_mut ( ) . as_mut ( ) . poll_next ( )
57
+ }
58
+ }
59
+
60
+ fn main ( ) {
61
+ let mut item = Box :: pin ( TryChunks ) ;
62
+ item. as_mut ( ) . poll_next ( ) ;
63
+ }
You can’t perform that action at this time.
0 commit comments