]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coercion/issue-37655.rs
Auto merge of #103590 - compiler-errors:ocx-more, r=lcnr
[rust.git] / src / test / ui / coercion / issue-37655.rs
1 // check-pass
2 // Regression test for #37655. The problem was a false edge created by
3 // coercion that wound up requiring that `'a` (in `split()`) outlive
4 // `'b`, which shouldn't be necessary.
5
6 #![allow(warnings)]
7
8 trait SliceExt<T> {
9     type Item;
10
11     fn get_me<I>(&self, index: I) -> &I::Output
12         where I: SliceIndex<Self::Item>;
13 }
14
15 impl<T> SliceExt<T> for [T] {
16     type Item = T;
17
18     fn get_me<I>(&self, index: I) -> &I::Output
19         where I: SliceIndex<T>
20     {
21         panic!()
22     }
23 }
24
25 pub trait SliceIndex<T> {
26     type Output: ?Sized;
27 }
28
29 impl<T> SliceIndex<T> for usize {
30     type Output = T;
31 }
32
33 fn foo<'a, 'b>(split: &'b [&'a [u8]]) -> &'a [u8] {
34     split.get_me(0)
35 }
36
37 fn main() { }