diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2021-02-02 12:14:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-02 12:14:59 +0100 |
| commit | efec2bbbce3c547559fed6a6398703f7041649c4 (patch) | |
| tree | db09e831a7aa03b9551e32b21aa3215b15fd844c /src | |
| parent | 30f12a037952d2c08348d3eae69b4185ac1b52ae (diff) | |
| parent | 7f8530f16b8cc908cb77970967addf39ae1a975d (diff) | |
| download | rust-efec2bbbce3c547559fed6a6398703f7041649c4.tar.gz rust-efec2bbbce3c547559fed6a6398703f7041649c4.zip | |
Rollup merge of #81577 - BoxyUwU:subexpr_const_evaluatable, r=oli-obk
const_evaluatable: consider sub-expressions to be evaluatable see [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const_evaluatable.3A.20subexpressions) for more info cc `@lcnr` r? `@oli-obk`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs b/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs index 1428f774b0d..4d0b87efc77 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs @@ -21,7 +21,6 @@ where fn substs3<const L: usize>() -> Substs1<{ (L - 1) * 2 }> where - [(); (L - 1)]: , [(); (L - 1) * 2 + 1]: , { substs2::<{ L - 1 }>() diff --git a/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs b/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs new file mode 100644 index 00000000000..11c0760cdfe --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs @@ -0,0 +1,17 @@ +// run-pass +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +fn make_array<const M: usize>() -> [(); M + 1] { + [(); M + 1] +} + +fn foo<const N: usize>() -> [(); (N * 2) + 1] { + make_array::<{ N * 2 }>() +} + +fn main() { + assert_eq!(foo::<10>(), [(); 10 * 2 + 1]) +} + +// Tests that N * 2 is considered const_evalutable by appearing as part of the (N * 2) + 1 const |
