implement calling of const fn-methods in true constants
This commit is contained in:
parent
e5aa92a0df
commit
8e64e22ef7
5 changed files with 56 additions and 29 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,5 @@ fn main() {
|
|||
|
||||
assert_eq!(DIFF, 22);
|
||||
|
||||
let _: [&'static str; sub(100, 99) as usize] = ["hi"];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue