rust/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs

37 lines
841 B
Rust
Raw Normal View History

2023-04-16 06:12:37 -05:00
// known-bug: #110395
2021-09-07 07:36:50 -05:00
#![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
2021-09-07 07:36:50 -05:00
#[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>() {}
2021-09-07 07:36:50 -05:00
fn main() {}