Skip to content

Commit

Permalink
Add regression test for #61522
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Apr 9, 2020
1 parent 61cc892 commit 0f02522
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/test/ui/const-generics/issue-61522-array-len-succ.rs
@@ -0,0 +1,14 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
//~^ ERROR constant expression depends on a generic parameter

impl<const COUNT: usize> MyArray<COUNT> {
fn inner(&self) -> &[u8; COUNT + 1] {
//~^ ERROR constant expression depends on a generic parameter
&self.0
}
}

fn main() {}
26 changes: 26 additions & 0 deletions src/test/ui/const-generics/issue-61522-array-len-succ.stderr
@@ -0,0 +1,26 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/issue-61522-array-len-succ.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error: constant expression depends on a generic parameter
--> $DIR/issue-61522-array-len-succ.rs:4:40
|
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
| ^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes

error: constant expression depends on a generic parameter
--> $DIR/issue-61522-array-len-succ.rs:8:24
|
LL | fn inner(&self) -> &[u8; COUNT + 1] {
| ^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes

error: aborting due to 2 previous errors

0 comments on commit 0f02522

Please sign in to comment.