Report let bindings and statements as unstable

This commit is contained in:
Oliver Schneider 2018-05-08 13:59:26 +02:00
parent d7bf358dbd
commit 8a5eb68958
No known key found for this signature in database
GPG key ID: 1D5CB4FC597C3004
16 changed files with 150 additions and 65 deletions

View file

@ -9,18 +9,20 @@
// except according to those terms.
const A: usize = { 1; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR statements in constants are unstable
const B: usize = { { } 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR statements in constants are unstable
macro_rules! foo {
() => (()) //~ ERROR: blocks in constants are limited to items and tail expressions
() => (()) //~ ERROR statements in constants are unstable
}
const C: usize = { foo!(); 2 };
const D: usize = { let x = 4; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
//~| ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
pub fn main() {}

View file

@ -9,7 +9,9 @@
// except according to those terms.
type Array = [u32; { let x = 2; 5 }];
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
//~| ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
pub fn main() {}

View file

@ -10,8 +10,10 @@
enum Foo {
Bar = { let x = 1; 3 }
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
//~| ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
}
pub fn main() {}

View file

@ -8,16 +8,20 @@
// 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
// test that certain things are disallowed in constant functionssignatures
#![feature(const_fn)]
// no destructuring
const fn i((
a, //~ ERROR: E0022
b //~ ERROR: E0022
a,
//~^ ERROR arguments of constant functions can only be immutable by-value bindings
b
//~^ ERROR arguments of constant functions can only be immutable by-value bindings
): (u32, u32)) -> u32 {
a + b
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR let bindings in constant functions are unstable
}
fn main() {}

View file

@ -38,9 +38,15 @@ const fn get_Y_addr() -> &'static u32 {
}
const fn get() -> u32 {
let x = 22; //~ ERROR E0016
let y = 44; //~ ERROR E0016
let x = 22;
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR statements in constant functions are unstable
let y = 44;
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR statements in constant functions are unstable
x + y
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR let bindings in constant functions are unstable
}
fn main() {

View file

@ -10,9 +10,12 @@
pub fn main() {
const z: &'static isize = {
//~^ ERROR blocks in constants are limited to items and tail expressions
//~^ ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
let p = 3;
//~^ ERROR blocks in constants are limited to items and tail expressions
//~^ ERROR let bindings in constants are unstable
//~| ERROR statements in constants are unstable
&p //~ ERROR `p` does not live long enough
//~^ ERROR let bindings in constants are unstable
};
}

View file

@ -11,8 +11,12 @@
#![feature(const_fn)]
const fn x() {
let t = true; //~ ERROR blocks in constant functions are limited to items and tail expressions
let x = || t; //~ ERROR blocks in constant functions are limited to items and tail expressions
let t = true;
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR statements in constant functions are unstable
let x = || t;
//~^ ERROR let bindings in constant functions are unstable
//~| ERROR statements in constant functions are unstable
}
fn main() {}

View file

@ -14,7 +14,8 @@
const bad : u32 = {
{
5; //~ ERROR: blocks in constants are limited to items and tail expressions
5;
//~^ ERROR statements in constants are unstable
0
}
};
@ -22,7 +23,7 @@ const bad : u32 = {
const bad_two : u32 = {
{
invalid();
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR statements in constants are unstable
//~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
0
}
@ -31,14 +32,15 @@ const bad_two : u32 = {
const bad_three : u32 = {
{
valid();
//~^ ERROR: blocks in constants are limited to items and tail expressions
//~^ ERROR statements in constants are unstable
0
}
};
static bad_four : u32 = {
{
5; //~ ERROR: blocks in statics are limited to items and tail expressions
5;
//~^ ERROR statements in statics are unstable
0
}
};
@ -46,8 +48,8 @@ static bad_four : u32 = {
static bad_five : u32 = {
{
invalid();
//~^ ERROR: blocks in statics are limited to items and tail expressions
//~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
//~| ERROR statements in statics are unstable
0
}
};
@ -55,14 +57,15 @@ static bad_five : u32 = {
static bad_six : u32 = {
{
valid();
//~^ ERROR: blocks in statics are limited to items and tail expressions
//~^ ERROR statements in statics are unstable
0
}
};
static mut bad_seven : u32 = {
{
5; //~ ERROR: blocks in statics are limited to items and tail expressions
5;
//~^ ERROR statements in statics are unstable
0
}
};
@ -70,8 +73,8 @@ static mut bad_seven : u32 = {
static mut bad_eight : u32 = {
{
invalid();
//~^ ERROR: blocks in statics are limited to items and tail expressions
//~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
//~^ ERROR statements in statics are unstable
//~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
0
}
};
@ -79,7 +82,7 @@ static mut bad_eight : u32 = {
static mut bad_nine : u32 = {
{
valid();
//~^ ERROR: blocks in statics are limited to items and tail expressions
//~^ ERROR statements in statics are unstable
0
}
};