summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/issue-88856.rs
blob: 7cae7c71cd2d01e0d5419a05d180eea09636bdc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// check-pass

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

pub trait Trait{
    type R;
    fn func(self)->Self::R;
}

pub struct TraitImpl<const N:usize>(pub i32);

impl<const N:usize> Trait for TraitImpl<N>
where [();N/2]:,
{
    type R = Self;
    fn func(self)->Self::R {
        self
    }
}

fn sample<P,Convert>(p:P,f:Convert) -> i32
where
    P:Trait,Convert:Fn(P::R)->i32
{
    f(p.func())
}

fn main() {
    let t = TraitImpl::<10>(4);
    sample(t,|x|x.0);
}