allow constant evaluation of function calls
This commit is contained in:
parent
9ed32bba77
commit
b4e30bd2a3
14 changed files with 155 additions and 52 deletions
|
|
@ -14,7 +14,7 @@
|
|||
struct S(i32);
|
||||
|
||||
const CONSTANT: S = S(0);
|
||||
//~^ ERROR: constant evaluation error: unsupported constant expr
|
||||
//~^ ERROR: constant evaluation error: non-constant path in constant expression [E0080]
|
||||
|
||||
enum E {
|
||||
V = CONSTANT,
|
||||
|
|
|
|||
18
src/test/compile-fail/const-fn-destructuring-arg.rs
Normal file
18
src/test/compile-fail/const-fn-destructuring-arg.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// test that certain things are disallowed in const fn signatures
|
||||
|
||||
#![feature(const_fn)]
|
||||
|
||||
// no destructuring
|
||||
const fn i((a, b): (u32, u32)) -> u32 { a + b } //~ ERROR: E0022
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -17,5 +17,5 @@ extern crate const_fn_lib;
|
|||
use const_fn_lib::foo;
|
||||
|
||||
fn main() {
|
||||
let x: [usize; foo()] = []; //~ ERROR unsupported constant expr
|
||||
let x: [usize; foo()] = []; //~ ERROR non-constant path in constant expr
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue