File tree 2 files changed +81
-0
lines changed
2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ allow( unreachable_code) ]
2
+
3
+ use std:: marker:: PhantomData ;
4
+ use std:: ops:: Deref ;
5
+ use std:: sync:: Arc ;
6
+
7
+ pub struct Guard < T > {
8
+ _phantom : PhantomData < T > ,
9
+ }
10
+ impl < T > Deref for Guard < T > {
11
+ type Target = T ;
12
+ fn deref ( & self ) -> & T {
13
+ unimplemented ! ( )
14
+ }
15
+ }
16
+
17
+ pub struct DirectDeref < T > ( T ) ;
18
+ impl < T > Deref for DirectDeref < Arc < T > > {
19
+ type Target = T ;
20
+ fn deref ( & self ) -> & T {
21
+ unimplemented ! ( )
22
+ }
23
+ }
24
+
25
+ pub trait Access < T > {
26
+ type Guard : Deref < Target = T > ;
27
+ fn load ( & self ) -> Self :: Guard {
28
+ unimplemented ! ( )
29
+ }
30
+ }
31
+ impl < T , A : Access < T > , P : Deref < Target = A > > Access < T > for P {
32
+ //~^ NOTE: required for `Arc<ArcSwapAny<Arc<usize>>>` to implement `Access<_>`
33
+ type Guard = A :: Guard ;
34
+ }
35
+ impl < T > Access < T > for ArcSwapAny < T > {
36
+ //~^ NOTE: multiple `impl`s satisfying `ArcSwapAny<Arc<usize>>: Access<_>` found
37
+ type Guard = Guard < T > ;
38
+ }
39
+ impl < T > Access < T > for ArcSwapAny < Arc < T > > {
40
+ type Guard = DirectDeref < Arc < T > > ;
41
+ }
42
+
43
+ pub struct ArcSwapAny < T > {
44
+ _phantom_arc : PhantomData < T > ,
45
+ }
46
+
47
+ pub fn foo ( ) {
48
+ let s: Arc < ArcSwapAny < Arc < usize > > > = unimplemented ! ( ) ;
49
+ let guard: Guard < Arc < usize > > = s. load ( ) ;
50
+ //~^ ERROR: type annotations needed
51
+ //~| HELP: try using a fully qualified path to specify the expected types
52
+ }
53
+
54
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0283]: type annotations needed
2
+ --> $DIR/issue-80816.rs:49:38
3
+ |
4
+ LL | let guard: Guard<Arc<usize>> = s.load();
5
+ | ^^^^
6
+ |
7
+ note: multiple `impl`s satisfying `ArcSwapAny<Arc<usize>>: Access<_>` found
8
+ --> $DIR/issue-80816.rs:35:1
9
+ |
10
+ LL | impl<T> Access<T> for ArcSwapAny<T> {
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+ ...
13
+ LL | impl<T> Access<T> for ArcSwapAny<Arc<T>> {
14
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15
+ note: required for `Arc<ArcSwapAny<Arc<usize>>>` to implement `Access<_>`
16
+ --> $DIR/issue-80816.rs:31:45
17
+ |
18
+ LL | impl<T, A: Access<T>, P: Deref<Target = A>> Access<T> for P {
19
+ | ^^^^^^^^^ ^
20
+ help: try using a fully qualified path to specify the expected types
21
+ |
22
+ LL | let guard: Guard<Arc<usize>> = <Arc<ArcSwapAny<Arc<usize>>> as Access<T>>::load(&s);
23
+ | ++++++++++++++++++++++++++++++++++++++++++++++++++ ~
24
+
25
+ error: aborting due to previous error
26
+
27
+ For more information about this error, try `rustc --explain E0283`.
You can’t perform that action at this time.
0 commit comments