]> git.lizzy.rs Git - rust.git/blob - tests/ui/resolve/issue-85671.rs
Rollup merge of #106244 - atouchet:readme3, r=workingjubilee
[rust.git] / tests / ui / resolve / issue-85671.rs
1 // check-pass
2
3 // Some trait with a function that returns a slice:
4 pub trait AsSlice {
5     type Element;
6     fn as_slice(&self) -> &[Self::Element];
7 }
8
9 // Some type
10 pub struct A<Cont>(Cont);
11
12 // Here we say that if A wraps a slice, then it implements AsSlice
13 impl<'a, Element> AsSlice for A<&'a [Element]> {
14     type Element = Element;
15     fn as_slice(&self) -> &[Self::Element] {
16         self.0
17     }
18 }
19
20 impl<Cont> A<Cont> {
21     // We want this function to work
22     pub fn failing<Coef>(&self)
23     where
24         Self: AsSlice<Element = Coef>,
25     {
26         self.as_ref_a().as_ref_a();
27     }
28
29     pub fn as_ref_a<Coef>(&self) -> A<&[<Self as AsSlice>::Element]>
30     where
31         Self: AsSlice<Element = Coef>,
32     {
33         A(self.as_slice())
34     }
35 }
36
37 fn main() {}