summaryrefslogtreecommitdiffstats
path: root/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs
blob: ae9207cf8555b66132b8cdbc771b2c3caad6378d (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
// known-bug: #110395

#![feature(generic_const_exprs, adt_const_params, const_trait_impl)]
#![allow(incomplete_features)]

// test `N + N` unifies with explicit function calls for non-builtin-types
#[derive(PartialEq, Eq)]
struct Foo(u8);

impl const std::ops::Add for Foo {
    type Output = Self;

    fn add(self, rhs: Self) -> Self::Output {
        self
    }
}

struct Evaluatable<const N: Foo>;

fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
    bar::<{ std::ops::Add::add(N, N) }>();
}

fn bar<const N: Foo>() {}

// test that `N + N` unifies with explicit function calls for builin-types
struct Evaluatable2<const N: usize>;

fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
    bar2::<{ std::ops::Add::add(N, N) }>();
    // FIXME(generic_const_exprs) make this not an error
}

fn bar2<const N: usize>() {}

fn main() {}