about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-06-05 13:25:17 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-06-05 13:25:17 +0200
commit192c1d0717f2ba123b449a021257f2df571242d2 (patch)
tree0327ba13d77dfcc3f7512240af7d7c42e9975149 /src/test
parentdcd46d6b67710b4991aebdb4d6e53b15fe26479a (diff)
downloadrust-192c1d0717f2ba123b449a021257f2df571242d2.tar.gz
rust-192c1d0717f2ba123b449a021257f2df571242d2.zip
Explain the existience of the regression test
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/const_arg_promotable2.rs11
-rw-r--r--src/test/ui/consts/const_arg_promotable2.stderr2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/test/ui/consts/const_arg_promotable2.rs b/src/test/ui/consts/const_arg_promotable2.rs
index 5d9400a907b..3399e51ed4e 100644
--- a/src/test/ui/consts/const_arg_promotable2.rs
+++ b/src/test/ui/consts/const_arg_promotable2.rs
@@ -1,3 +1,8 @@
+// This test is a regression test for a bug where we only checked function calls in no-const
+// functions for `rustc_args_required_const` arguments. This meant that even though `bar` needs its
+// argument to be const, inside a const fn (callable at runtime), the value for it may come from a
+// non-constant (namely an argument to the const fn).
+
 #![feature(rustc_attrs)]
 const fn foo(a: i32) {
     bar(a); //~ ERROR argument 1 is required to be a constant
@@ -6,4 +11,8 @@ const fn foo(a: i32) {
 #[rustc_args_required_const(0)]
 const fn bar(_: i32) {}
 
-fn main() {}
+fn main() {
+    // this function call will pass a runtime-value (number of program arguments) to `foo`, which
+    // will in turn forward it to `bar`, which expects a compile-time argument
+    foo(std::env::args().count() as i32);
+}
diff --git a/src/test/ui/consts/const_arg_promotable2.stderr b/src/test/ui/consts/const_arg_promotable2.stderr
index 67a1132f830..149d1ce8940 100644
--- a/src/test/ui/consts/const_arg_promotable2.stderr
+++ b/src/test/ui/consts/const_arg_promotable2.stderr
@@ -1,5 +1,5 @@
 error: argument 1 is required to be a constant
-  --> $DIR/const_arg_promotable2.rs:3:5
+  --> $DIR/const_arg_promotable2.rs:8:5
    |
 LL |     bar(a);
    |     ^^^^^^