diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-10-23 12:13:44 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-10-23 12:16:58 +0200 |
| commit | 6ad140ca197a1147e476f34908c2b69a60cc6d2f (patch) | |
| tree | c865da58b170f1829027bcb0902897a4f39a35a4 /src/test | |
| parent | a9cd294cf2775441e713c7ee2918b728733b99f5 (diff) | |
const_eval_checked: deal with unused nodes + div
Diffstat (limited to 'src/test')
3 files changed, 62 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/division.rs b/src/test/ui/const-generics/const_evaluatable_checked/division.rs new file mode 100644 index 00000000000..71a5f2d3472 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/division.rs @@ -0,0 +1,11 @@ +// run-pass +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +fn with_bound<const N: usize>() where [u8; N / 2]: Sized { + let _: [u8; N / 2] = [0; N / 2]; +} + +fn main() { + with_bound::<4>(); +} diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs b/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs new file mode 100644 index 00000000000..9c603c57a48 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs @@ -0,0 +1,25 @@ +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +fn add<const N: usize>() -> [u8; { N + 1; 5 }] { + //~^ ERROR overly complex generic constant + todo!() +} + +fn div<const N: usize>() -> [u8; { N / 1; 5 }] { + //~^ ERROR overly complex generic constant + todo!() +} + +const fn foo(n: usize) {} + +fn fn_call<const N: usize>() -> [u8; { foo(N); 5 }] { + //~^ ERROR overly complex generic constant + todo!() +} + +fn main() { + add::<12>(); + div::<9>(); + fn_call::<14>(); +} diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.stderr b/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.stderr new file mode 100644 index 00000000000..73c6d9393ce --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.stderr @@ -0,0 +1,26 @@ +error: overly complex generic constant + --> $DIR/unused_expr.rs:4:34 + | +LL | fn add<const N: usize>() -> [u8; { N + 1; 5 }] { + | ^^^^^^^^^^^^ unused node + | + = help: consider moving this anonymous constant into a `const` function + +error: overly complex generic constant + --> $DIR/unused_expr.rs:9:34 + | +LL | fn div<const N: usize>() -> [u8; { N / 1; 5 }] { + | ^^^^^^^^^^^^ unused node + | + = help: consider moving this anonymous constant into a `const` function + +error: overly complex generic constant + --> $DIR/unused_expr.rs:16:38 + | +LL | fn fn_call<const N: usize>() -> [u8; { foo(N); 5 }] { + | ^^^^^^^^^^^^^ unused node + | + = help: consider moving this anonymous constant into a `const` function + +error: aborting due to 3 previous errors + |
