implement calling of const fn-methods in true constants

This commit is contained in:
Oliver Schneider 2015-11-27 16:43:24 +01:00
parent e5aa92a0df
commit 8e64e22ef7
5 changed files with 56 additions and 29 deletions

View file

@ -14,7 +14,7 @@
struct S(i32);
const CONSTANT: S = S(0);
//~^ ERROR: constant evaluation error: non-constant path in constant expression [E0080]
//~^ ERROR: constant evaluation error: call on struct [E0080]
enum E {
V = CONSTANT,

View file

@ -17,5 +17,6 @@ extern crate const_fn_lib;
use const_fn_lib::foo;
fn main() {
let x: [usize; foo()] = []; //~ ERROR non-constant path in constant expr
let x: [usize; foo()] = [];
//~^ ERROR unimplemented constant expression: calling non-local const fn [E0250]
}

View file

@ -22,4 +22,5 @@ const FOO: Foo = Foo::new();
pub fn main() {
assert_eq!(FOO.value, 22);
let _: [&'static str; Foo::new().value as usize] = ["hey"; 22];
}

View file

@ -29,4 +29,5 @@ fn main() {
assert_eq!(DIFF, 22);
let _: [&'static str; sub(100, 99) as usize] = ["hi"];
}