about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkrk <keremkat@gmail.com>2018-04-17 18:59:27 +0300
committerkrk <keremkat@gmail.com>2018-04-18 10:56:43 +0300
commitb39b3a2f49cb1147dcbdf4d554b4cc8c677c3d43 (patch)
treebd194a906470fb3738edc202f85140ad10675095
parentd703622ce08d51eb91a909278f7917762e743438 (diff)
downloadrust-b39b3a2f49cb1147dcbdf4d554b4cc8c677c3d43.tar.gz
rust-b39b3a2f49cb1147dcbdf4d554b4cc8c677c3d43.zip
Clarified E0015 message, r=estebank
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs4
-rw-r--r--src/test/compile-fail/issue-43105.rs2
-rw-r--r--src/test/compile-fail/issue32829.rs9
-rw-r--r--src/test/ui/const-fn-error.stderr2
-rw-r--r--src/test/ui/mir_check_nonconst.rs21
-rw-r--r--src/test/ui/mir_check_nonconst.stderr9
6 files changed, 40 insertions, 7 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index aeefd5ab1d5..591732fbba9 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -964,7 +964,7 @@ This does not pose a problem by itself because they can't be accessed directly."
                     let (msg, note) = if let UnstableFeatures::Disallow =
                             self.tcx.sess.opts.unstable_features {
                         (format!("calls in {}s are limited to \
-                                  struct and enum constructors",
+                                  tuple structs and tuple variants",
                                  self.mode),
                          Some("a limited form of compile-time function \
                                evaluation is available on a nightly \
@@ -972,7 +972,7 @@ This does not pose a problem by itself because they can't be accessed directly."
                     } else {
                         (format!("calls in {}s are limited \
                                   to constant functions, \
-                                  struct and enum constructors",
+                                  tuple structs and tuple variants",
                                  self.mode),
                          None)
                     };
diff --git a/src/test/compile-fail/issue-43105.rs b/src/test/compile-fail/issue-43105.rs
index c0af3b4b9e6..6fa65a541b3 100644
--- a/src/test/compile-fail/issue-43105.rs
+++ b/src/test/compile-fail/issue-43105.rs
@@ -11,7 +11,7 @@
 fn xyz() -> u8 { 42 }
 
 const NUM: u8 = xyz();
-//~^ ERROR calls in constants are limited to constant functions, struct and enum constructors
+//~^ ERROR calls in constants are limited to constant functions, tuple structs and tuple variants
 //~| ERROR constant evaluation error
 
 fn main() {
diff --git a/src/test/compile-fail/issue32829.rs b/src/test/compile-fail/issue32829.rs
index e0b847fc994..9a84322ad06 100644
--- a/src/test/compile-fail/issue32829.rs
+++ b/src/test/compile-fail/issue32829.rs
@@ -7,6 +7,9 @@
 // <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.
+
+// ignore-tidy-linelength
+
 #![feature(const_fn)]
 
 const bad : u32 = {
@@ -20,7 +23,7 @@ const bad_two : u32 = {
     {
         invalid();
         //~^ ERROR: blocks in constants are limited to items and tail expressions
-        //~^^ ERROR: calls in constants are limited to constant functions, struct and enum
+        //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
         0
     }
 };
@@ -44,7 +47,7 @@ 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, struct and enum
+        //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
         0
     }
 };
@@ -68,7 +71,7 @@ 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, struct and enum
+        //~^^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
         0
     }
 };
diff --git a/src/test/ui/const-fn-error.stderr b/src/test/ui/const-fn-error.stderr
index 077c4d60e64..767f28ff7b1 100644
--- a/src/test/ui/const-fn-error.stderr
+++ b/src/test/ui/const-fn-error.stderr
@@ -4,7 +4,7 @@ error[E0016]: blocks in constant functions are limited to items and tail express
 LL |     let mut sum = 0;
    |                   ^
 
-error[E0015]: calls in constant functions are limited to constant functions, struct and enum constructors
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
   --> $DIR/const-fn-error.rs:18:14
    |
 LL |     for i in 0..x {
diff --git a/src/test/ui/mir_check_nonconst.rs b/src/test/ui/mir_check_nonconst.rs
new file mode 100644
index 00000000000..898ee8bbd44
--- /dev/null
+++ b/src/test/ui/mir_check_nonconst.rs
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+#![allow(dead_code)]
+
+struct Foo { a: u8 }
+fn bar() -> Foo {
+    Foo { a: 5 }
+}
+
+static foo: Foo = bar();
+//~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants
+
+fn main() {}
diff --git a/src/test/ui/mir_check_nonconst.stderr b/src/test/ui/mir_check_nonconst.stderr
new file mode 100644
index 00000000000..1fddaf30576
--- /dev/null
+++ b/src/test/ui/mir_check_nonconst.stderr
@@ -0,0 +1,9 @@
+error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
+  --> $DIR/mir_check_nonconst.rs:18:19
+   |
+LL | static foo: Foo = bar();
+   |                   ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0015`.