File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/test/ui/const-generics/issues Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ // Regression test for #62504
2+
3+ #![ feature( const_generics) ]
4+ #![ allow( incomplete_features) ]
5+
6+ trait HasSize {
7+ const SIZE : usize ;
8+ }
9+
10+ impl < const X : usize > HasSize for ArrayHolder < { X } > {
11+ const SIZE : usize = X ;
12+ }
13+
14+ struct ArrayHolder < const X : usize > ( [ u32 ; X ] ) ;
15+
16+ impl < const X : usize > ArrayHolder < { X } > {
17+ pub const fn new ( ) -> Self {
18+ ArrayHolder ( [ 0 ; Self :: SIZE ] )
19+ //~^ ERROR: array lengths can't depend on generic parameters
20+ }
21+ }
22+
23+ fn main ( ) {
24+ let mut array = ArrayHolder :: new ( ) ;
25+ }
Original file line number Diff line number Diff line change 1+ error: array lengths can't depend on generic parameters
2+ --> $DIR/issue-62504.rs:18:25
3+ |
4+ LL | ArrayHolder([0; Self::SIZE])
5+ | ^^^^^^^^^^
6+
7+ error: aborting due to previous error
8+
You can’t perform that action at this time.
0 commit comments