-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/test/ui/const-generics/array-size-in-generic-struct-param.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// run-pass | ||
|
||
#![feature(const_generics)] | ||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
#[allow(dead_code)] | ||
struct ArithArrayLen<const N: usize>([u32; 0 + N]); // ok | ||
|
||
#[derive(PartialEq, Eq)] | ||
struct Config { | ||
arr_size: usize, | ||
} | ||
|
||
struct B<const CFG: Config> { | ||
arr: [u8; CFG.arr_size], // ok | ||
} | ||
|
||
const C: Config = Config { arr_size: 5 }; | ||
|
||
fn main() { | ||
let b = B::<C> { arr: [1, 2, 3, 4, 5] }; | ||
assert_eq!(b.arr.len(), 5); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash | ||
--> $DIR/array-size-in-generic-struct-param.rs:3:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|