This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +39
-4
lines changed
issues/issue-50264-inner-deref-trait Expand file tree Collapse file tree 5 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ LL | let _result = &Some(42).as_deref();
66 |
77 = note: the following trait bounds were not satisfied:
88 `{integer}: Deref`
9- `<{integer} as Deref>::Target = _`
109
1110error: aborting due to previous error
1211
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ LL | let _result = &mut Some(42).as_deref_mut();
66 |
77 = note: the following trait bounds were not satisfied:
88 `{integer}: DerefMut`
9- `< {integer} as Deref>::Target = _ `
9+ `{integer}: Deref `
1010
1111error: aborting due to previous error
1212
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ LL | let _result = &Ok(42).as_deref();
66 |
77 = note: the following trait bounds were not satisfied:
88 `{integer}: Deref`
9- `<{integer} as Deref>::Target = _`
109
1110error: aborting due to previous error
1211
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ LL | let _result = &mut Ok(42).as_deref_mut();
66 |
77 = note: the following trait bounds were not satisfied:
88 `{integer}: DerefMut`
9- `< {integer} as Deref>::Target = _ `
9+ `{integer}: Deref `
1010
1111error: aborting due to previous error
1212
Original file line number Diff line number Diff line change 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 ( ) { }
You can’t perform that action at this time.
0 commit comments