rust/tests/ui/const-generics/generic_const_exprs/issue-62504.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
661 B
Rust
Raw Normal View History

// revisions: full min
2020-03-12 19:03:58 -05:00
#![allow(incomplete_features)]
#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
2020-03-12 19:03:58 -05:00
trait HasSize {
const SIZE: usize;
}
2020-03-27 15:56:19 -05:00
impl<const X: usize> HasSize for ArrayHolder<X> {
2020-03-12 19:03:58 -05:00
const SIZE: usize = X;
}
struct ArrayHolder<const X: usize>([u32; X]);
2020-03-27 15:56:19 -05:00
impl<const X: usize> ArrayHolder<X> {
2020-03-12 19:03:58 -05:00
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
//~^ ERROR mismatched types
//[full]~^^ ERROR unconstrained generic constant
//[min]~^^^ ERROR constant expression depends on a generic parameter
2020-03-12 19:03:58 -05:00
}
}
fn main() {
let mut array = ArrayHolder::new();
}