]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / const-generics / generic_const_exprs / unify-op-with-fn-call.rs
1 #![feature(generic_const_exprs, adt_const_params, const_trait_impl)]
2 #![allow(incomplete_features)]
3
4 // test `N + N` unifies with explicit function calls for non-builtin-types
5 #[derive(PartialEq, Eq)]
6 struct Foo(u8);
7
8 impl const std::ops::Add for Foo {
9     type Output = Self;
10
11     fn add(self, rhs: Self) -> Self::Output {
12         self
13     }
14 }
15
16 struct Evaluatable<const N: Foo>;
17
18 fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
19     bar::<{ std::ops::Add::add(N, N) }>();
20 }
21
22 fn bar<const N: Foo>() {}
23
24 // test that `N + N` unifies with explicit function calls for builin-types
25 struct Evaluatable2<const N: usize>;
26
27 fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
28     bar2::<{ std::ops::Add::add(N, N) }>();
29     //~^ error: unconstrained generic constant
30     // FIXME(generic_const_exprs) make this not an error
31 }
32
33 fn bar2<const N: usize>() {}
34
35 fn main() {}