about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2018-05-08 13:59:26 +0200
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2018-05-22 10:54:05 +0200
commit8a5eb689583163eef39e6b595506341ebfe19633 (patch)
tree3caa678bf5543b2b945904e9e94f339bdd0f9062 /src/test
parentd7bf358dbd778f2c0a32936b959e868918e082ca (diff)
downloadrust-8a5eb689583163eef39e6b595506341ebfe19633.tar.gz
rust-8a5eb689583163eef39e6b595506341ebfe19633.zip
Report let bindings and statements as unstable
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/const-block-non-item-statement-2.rs12
-rw-r--r--src/test/compile-fail/const-block-non-item-statement-3.rs6
-rw-r--r--src/test/compile-fail/const-block-non-item-statement.rs6
-rw-r--r--src/test/compile-fail/const-fn-destructuring-arg.rs10
-rw-r--r--src/test/compile-fail/const-fn-not-safe-for-const.rs10
-rw-r--r--src/test/compile-fail/issue-18118.rs7
-rw-r--r--src/test/compile-fail/issue-37550.rs8
-rw-r--r--src/test/compile-fail/issue32829.rs25
-rw-r--r--src/test/run-pass/ctfe/const-fn-destructuring-arg.rs2
-rw-r--r--src/test/ui/const-eval/const_let.rs30
-rw-r--r--src/test/ui/const-eval/const_let.stderr15
-rw-r--r--src/test/ui/const-fn-error.rs3
-rw-r--r--src/test/ui/const-fn-error.stderr24
-rw-r--r--src/test/ui/feature-gate-const_let.rs4
-rw-r--r--src/test/ui/feature-gate-const_let.stderr18
15 files changed, 137 insertions, 43 deletions
diff --git a/src/test/compile-fail/const-block-non-item-statement-2.rs b/src/test/compile-fail/const-block-non-item-statement-2.rs
index 83166c9bd4b..f80d55cb342 100644
--- a/src/test/compile-fail/const-block-non-item-statement-2.rs
+++ b/src/test/compile-fail/const-block-non-item-statement-2.rs
@@ -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() {}
diff --git a/src/test/compile-fail/const-block-non-item-statement-3.rs b/src/test/compile-fail/const-block-non-item-statement-3.rs
index 70703791101..cfa4b778dde 100644
--- a/src/test/compile-fail/const-block-non-item-statement-3.rs
+++ b/src/test/compile-fail/const-block-non-item-statement-3.rs
@@ -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() {}
diff --git a/src/test/compile-fail/const-block-non-item-statement.rs b/src/test/compile-fail/const-block-non-item-statement.rs
index 802e660b904..f974a24c26f 100644
--- a/src/test/compile-fail/const-block-non-item-statement.rs
+++ b/src/test/compile-fail/const-block-non-item-statement.rs
@@ -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() {}
diff --git a/src/test/compile-fail/const-fn-destructuring-arg.rs b/src/test/compile-fail/const-fn-destructuring-arg.rs
index c3d5975fe01..e239bd701c5 100644
--- a/src/test/compile-fail/const-fn-destructuring-arg.rs
+++ b/src/test/compile-fail/const-fn-destructuring-arg.rs
@@ -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() {}
diff --git a/src/test/compile-fail/const-fn-not-safe-for-const.rs b/src/test/compile-fail/const-fn-not-safe-for-const.rs
index 48877a60d25..d985bae1f24 100644
--- a/src/test/compile-fail/const-fn-not-safe-for-const.rs
+++ b/src/test/compile-fail/const-fn-not-safe-for-const.rs
@@ -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() {
diff --git a/src/test/compile-fail/issue-18118.rs b/src/test/compile-fail/issue-18118.rs
index 35e57dffb6c..7194c159c1e 100644
--- a/src/test/compile-fail/issue-18118.rs
+++ b/src/test/compile-fail/issue-18118.rs
@@ -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
     };
 }
diff --git a/src/test/compile-fail/issue-37550.rs b/src/test/compile-fail/issue-37550.rs
index e1f7f64e01a..af1f6ef5ed4 100644
--- a/src/test/compile-fail/issue-37550.rs
+++ b/src/test/compile-fail/issue-37550.rs
@@ -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() {}
diff --git a/src/test/compile-fail/issue32829.rs b/src/test/compile-fail/issue32829.rs
index 9a84322ad06..2b223bac8e6 100644
--- a/src/test/compile-fail/issue32829.rs
+++ b/src/test/compile-fail/issue32829.rs
@@ -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
     }
 };
diff --git a/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs b/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs
index a73a15b1762..d22c94074fb 100644
--- a/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs
+++ b/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs
@@ -8,7 +8,7 @@
 // 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, const_let)]
 
diff --git a/src/test/ui/const-eval/const_let.rs b/src/test/ui/const-eval/const_let.rs
new file mode 100644
index 00000000000..602d4da24f3
--- /dev/null
+++ b/src/test/ui/const-eval/const_let.rs
@@ -0,0 +1,30 @@
+// Copyright 2018 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.
+
+#![feature(const_let)]
+
+fn main() {}
+
+struct FakeNeedsDrop;
+
+impl Drop for FakeNeedsDrop {
+    fn drop(&mut self) {}
+}
+
+// ok
+const X: FakeNeedsDrop = { let x = FakeNeedsDrop; x };
+
+// error
+const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
+//~^ ERROR constant contains unimplemented expression type
+
+// error
+const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
+//~^ ERROR constant contains unimplemented expression type
diff --git a/src/test/ui/const-eval/const_let.stderr b/src/test/ui/const-eval/const_let.stderr
new file mode 100644
index 00000000000..86e3482fda6
--- /dev/null
+++ b/src/test/ui/const-eval/const_let.stderr
@@ -0,0 +1,15 @@
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const_let.rs:25:55
+   |
+LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
+   |                                                       ^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const_let.rs:29:35
+   |
+LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
+   |                                   ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/const-fn-error.rs b/src/test/ui/const-fn-error.rs
index 9e09f66776c..17dc9f94fe1 100644
--- a/src/test/ui/const-fn-error.rs
+++ b/src/test/ui/const-fn-error.rs
@@ -14,7 +14,8 @@ const X : usize = 2;
 
 const fn f(x: usize) -> usize {
     let mut sum = 0;
-    //~^ ERROR E0016
+    //~^ let bindings in constant functions are unstable
+    //~| statements in constant functions are unstable
     for i in 0..x {
         //~^ ERROR E0015
         //~| ERROR E0019
diff --git a/src/test/ui/const-fn-error.stderr b/src/test/ui/const-fn-error.stderr
index 767f28ff7b1..29edc2756af 100644
--- a/src/test/ui/const-fn-error.stderr
+++ b/src/test/ui/const-fn-error.stderr
@@ -1,23 +1,33 @@
-error[E0016]: blocks in constant functions are limited to items and tail expressions
+error[E0658]: let bindings in constant functions are unstable (see issue #48821)
   --> $DIR/const-fn-error.rs:16:19
    |
 LL |     let mut sum = 0;
    |                   ^
+   |
+   = help: add #![feature(const_let)] to the crate attributes to enable
+
+error[E0658]: statements in constant functions are unstable (see issue #48821)
+  --> $DIR/const-fn-error.rs:16:19
+   |
+LL |     let mut sum = 0;
+   |                   ^
+   |
+   = help: add #![feature(const_let)] to the crate attributes to enable
 
 error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/const-fn-error.rs:18:14
+  --> $DIR/const-fn-error.rs:19:14
    |
 LL |     for i in 0..x {
    |              ^^^^
 
 error[E0019]: constant function contains unimplemented expression type
-  --> $DIR/const-fn-error.rs:18:14
+  --> $DIR/const-fn-error.rs:19:14
    |
 LL |     for i in 0..x {
    |              ^^^^
 
 error[E0080]: constant evaluation error
-  --> $DIR/const-fn-error.rs:18:14
+  --> $DIR/const-fn-error.rs:19:14
    |
 LL |     for i in 0..x {
    |              ^^^^ calling non-const fn `<I as std::iter::IntoIterator><std::ops::Range<usize>>::into_iter`
@@ -26,12 +36,12 @@ LL |     let a : [i32; f(X)];
    |                   ---- inside call to `f`
    |
 note: for constant expression here
-  --> $DIR/const-fn-error.rs:29:13
+  --> $DIR/const-fn-error.rs:30:13
    |
 LL |     let a : [i32; f(X)];
    |             ^^^^^^^^^^^
 
-error: aborting due to 4 previous errors
+error: aborting due to 5 previous errors
 
-Some errors occurred: E0015, E0016, E0019, E0080.
+Some errors occurred: E0015, E0019, E0080, E0658.
 For more information about an error, try `rustc --explain E0015`.
diff --git a/src/test/ui/feature-gate-const_let.rs b/src/test/ui/feature-gate-const_let.rs
index 04d2fd5ccd1..05d02e62bc8 100644
--- a/src/test/ui/feature-gate-const_let.rs
+++ b/src/test/ui/feature-gate-const_let.rs
@@ -13,7 +13,9 @@
 #![feature(const_fn)]
 
 const fn foo() -> usize {
-    let x = 42; //~ ERROR blocks in constant functions are limited to items and tail expressions
+    let x = 42;
+    //~^ ERROR statements in constant functions are unstable
+    //~| ERROR: let bindings in constant functions are unstable
     42
 }
 
diff --git a/src/test/ui/feature-gate-const_let.stderr b/src/test/ui/feature-gate-const_let.stderr
index a07281ded8d..6a7f6255678 100644
--- a/src/test/ui/feature-gate-const_let.stderr
+++ b/src/test/ui/feature-gate-const_let.stderr
@@ -1,9 +1,19 @@
-error[E0016]: blocks in constant functions are limited to items and tail expressions
+error[E0658]: let bindings in constant functions are unstable (see issue #48821)
   --> $DIR/feature-gate-const_let.rs:16:13
    |
-LL |     let x = 42; //~ ERROR blocks in constant functions are limited to items and tail expressions
+LL |     let x = 42;
    |             ^^
+   |
+   = help: add #![feature(const_let)] to the crate attributes to enable
+
+error[E0658]: statements in constant functions are unstable (see issue #48821)
+  --> $DIR/feature-gate-const_let.rs:16:13
+   |
+LL |     let x = 42;
+   |             ^^
+   |
+   = help: add #![feature(const_let)] to the crate attributes to enable
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0016`.
+For more information about this error, try `rustc --explain E0658`.