about summary refs log tree commit diff
path: root/src/test/ui/invalid
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2021-02-25 09:04:43 +0000
committerAmanieu d'Antras <amanieu@gmail.com>2021-02-25 09:04:43 +0000
commit00afbe70f2f5cb0b6455036f4b97537ff77f2052 (patch)
tree86d680d056e882c9515c5b781c470d5bfeb16621 /src/test/ui/invalid
parent22184a0f5d0e83d07425d6058e7ad93c78160233 (diff)
downloadrust-00afbe70f2f5cb0b6455036f4b97537ff77f2052.tar.gz
rust-00afbe70f2f5cb0b6455036f4b97537ff77f2052.zip
Improve checking for attribute
Diffstat (limited to 'src/test/ui/invalid')
-rw-r--r--src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs14
-rw-r--r--src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr31
2 files changed, 29 insertions, 16 deletions
diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
index bf3f80807e6..3d8478f06db 100644
--- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
+++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
@@ -1,29 +1,29 @@
 #![feature(rustc_attrs)]
 
-#[rustc_legacy_const_generics(0)] //~ ERROR index exceeds number of arguments
+#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] must have one index for
 fn foo1() {}
 
 #[rustc_legacy_const_generics(1)] //~ ERROR index exceeds number of arguments
-fn foo2(_: u8) {}
+fn foo2<const X: usize>() {}
 
 #[rustc_legacy_const_generics(2)] //~ ERROR index exceeds number of arguments
 fn foo3<const X: usize>(_: u8) {}
 
 #[rustc_legacy_const_generics(a)] //~ ERROR arguments should be non-negative integers
-fn foo4() {}
+fn foo4<const X: usize>() {}
 
 #[rustc_legacy_const_generics(1, a, 2, b)] //~ ERROR arguments should be non-negative integers
-fn foo5(_: u8, _: u8, _: u8) {}
+fn foo5<const X: usize, const Y: usize, const Z: usize, const W: usize>() {}
 
 #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
 struct S;
 
 #[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes
-fn foo6(_: u8) {}
+fn foo6<const X: usize>() {}
 
 extern {
-    #[rustc_legacy_const_generics(1)] //~ ERROR index exceeds number of arguments
-    fn foo7(_: u8);
+    #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function
+    fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters
 }
 
 #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have
diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr
index 0d9960a663e..1f55a8e72d2 100644
--- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr
+++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr
@@ -18,11 +18,13 @@ error: malformed `rustc_legacy_const_generics` attribute input
 LL | #[rustc_legacy_const_generics = 1]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
 
-error: index exceeds number of arguments
-  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:3:31
+error: #[rustc_legacy_const_generics] must have one index for each generic parameter
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:3:1
    |
 LL | #[rustc_legacy_const_generics(0)]
-   |                               ^ there are only 0 arguments
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn foo1() {}
+   |        - generic parameters
 
 error: index exceeds number of arguments
   --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:6:31
@@ -57,18 +59,29 @@ LL | struct S;
    | --------- not a function
 
 error: #[rustc_legacy_const_generics] functions must only have const generics
-  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:29:31
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:29:1
    |
 LL | #[rustc_legacy_const_generics(0)]
-   |                               ^
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL | fn foo8<X>() {}
    |         - non-const generic parameter
 
-error: index exceeds number of arguments
-  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:35
+error: attribute should be applied to a function
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5
    |
 LL |     #[rustc_legacy_const_generics(1)]
-   |                                   ^ there is only 1 argument
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     fn foo7<const X: usize>();
+   |     -------------------------- not a function
+
+error[E0044]: foreign items may not have const parameters
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:26:5
+   |
+LL |     fn foo7<const X: usize>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
+   |
+   = help: replace the const parameters with concrete consts
 
-error: aborting due to 11 previous errors
+error: aborting due to 12 previous errors
 
+For more information about this error, try `rustc --explain E0044`.