]> git.lizzy.rs Git - rust.git/blob - tests/ui/inference/issue-80816.rs
Auto merge of #106827 - alexcrichton:update-llvm-to-15.0.7, r=cuviper
[rust.git] / tests / ui / inference / issue-80816.rs
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     //~| NOTE unsatisfied trait bound introduced here
34     type Guard = A::Guard;
35 }
36 impl<T> Access<T> for ArcSwapAny<T> {
37     //~^ NOTE: multiple `impl`s satisfying `ArcSwapAny<Arc<usize>>: Access<_>` found
38     type Guard = Guard<T>;
39 }
40 impl<T> Access<T> for ArcSwapAny<Arc<T>> {
41     type Guard = DirectDeref<Arc<T>>;
42 }
43
44 pub struct ArcSwapAny<T> {
45     _phantom_arc: PhantomData<T>,
46 }
47
48 pub fn foo() {
49     let s: Arc<ArcSwapAny<Arc<usize>>> = unimplemented!();
50     let guard: Guard<Arc<usize>> = s.load();
51     //~^ ERROR: type annotations needed
52     //~| HELP: try using a fully qualified path to specify the expected types
53 }
54
55 fn main() {}