]> git.lizzy.rs Git - rust.git/commit
Auto merge of #26848 - oli-obk:const_fn_const_eval, r=pnkfelix
authorbors <bors@rust-lang.org>
Tue, 27 Oct 2015 17:11:13 +0000 (17:11 +0000)
committerbors <bors@rust-lang.org>
Tue, 27 Oct 2015 17:11:13 +0000 (17:11 +0000)
commit540fd3aa715c8af7efb4b06b7f9ab6da398deb62
tree0feb30ef01a22ace949e54c28244c4ed326a2f1f
parent679b5a9faaed845bf4a4bd8fe27a2a98df78b7ad
parent2b000feba57a324534008356909e02394784cfcc
Auto merge of #26848 - oli-obk:const_fn_const_eval, r=pnkfelix

this has the funky side-effect of also allowing constant evaluation of function calls to functions that are not `const fn` as long as `check_const` didn't mark that function `NOT_CONST`

It's still not possible to call a normal function from a `const fn`, but let statements' initialization value can get const evaluated (this caused the fallout in the overflowing tests)

we can now do this:

```rust
const fn add(x: usize, y: usize) -> usize { x + y }
const ARR: [i32; add(1, 2)] = [5, 6, 7];
```

also added a test for destructuring in const fn args
```rust
const fn i((a, b): (u32, u32)) -> u32 { a + b } //~ ERROR: E0022
```

This is a **[breaking change]**, since it turns some runtime panics into compile-time errors. This statement is true for ANY improvement to the const evaluator.
src/librustc/middle/check_match.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs