summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/generic_const_exprs/issue-83765.rs
blob: fac811d1302fa1439b54e344bcf270af7168888d (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
33
34
35
36
37
38
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

trait TensorDimension {
    const DIM: usize;
}

trait TensorSize: TensorDimension {
    fn size(&self) -> [usize; Self::DIM];
}

trait Broadcastable: TensorSize + Sized {
    type Element;
    fn lazy_updim<const NEWDIM: usize>(&self, size: [usize; NEWDIM]) {}
}

struct BMap<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> {
    reference: &'a T,
    closure: F,
}

impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorDimension
    for BMap<'a, R, T, F, DIM>
{
    const DIM: usize = DIM;
}
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSize
    for BMap<'a, R, T, F, DIM>
{
    fn size(&self) -> [usize; DIM] {
        //~^ ERROR: method not compatible with trait [E0308]
        self.reference.size()
        //~^ ERROR: unconstrained generic constant
        //~| ERROR: mismatched types
    }
}

fn main() {}