about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-10-11 02:36:20 +0100
committervarkor <github@varkor.com>2019-10-25 23:26:27 +0100
commit4552c8f2f7c20ff5bb7e23b31b4aa863b4502903 (patch)
tree022d19a4e825d8b0233cc9680909efe03a059738
parentaf2b49777659c014e8e0e6827c379635003cfd69 (diff)
downloadrust-4552c8f2f7c20ff5bb7e23b31b4aa863b4502903.tar.gz
rust-4552c8f2f7c20ff5bb7e23b31b4aa863b4502903.zip
Add test for attribute error checking on trait and foreign items
-rw-r--r--src/test/ui/lint/inline-trait-and-foreign-items.rs19
-rw-r--r--src/test/ui/lint/inline-trait-and-foreign-items.stderr35
2 files changed, 54 insertions, 0 deletions
diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.rs b/src/test/ui/lint/inline-trait-and-foreign-items.rs
new file mode 100644
index 00000000000..30353d26831
--- /dev/null
+++ b/src/test/ui/lint/inline-trait-and-foreign-items.rs
@@ -0,0 +1,19 @@
+#![feature(extern_types)]
+
+trait Trait {
+    #[inline] //~ ERROR attribute should be applied to function or closure
+    const X: u32;
+
+    #[inline] //~ ERROR attribute should be applied to function or closure
+    type T;
+}
+
+extern {
+    #[inline] //~ ERROR attribute should be applied to function or closure
+    static X: u32;
+
+    #[inline] //~ ERROR attribute should be applied to function or closure
+    type T;
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr
new file mode 100644
index 00000000000..510fe26d061
--- /dev/null
+++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr
@@ -0,0 +1,35 @@
+error[E0518]: attribute should be applied to function or closure
+  --> $DIR/inline-trait-and-foreign-items.rs:12:5
+   |
+LL |     #[inline]
+   |     ^^^^^^^^^
+LL |     static X: u32;
+   |     -------------- not a function or closure
+
+error[E0518]: attribute should be applied to function or closure
+  --> $DIR/inline-trait-and-foreign-items.rs:15:5
+   |
+LL |     #[inline]
+   |     ^^^^^^^^^
+LL |     type T;
+   |     ------- not a function or closure
+
+error[E0518]: attribute should be applied to function or closure
+  --> $DIR/inline-trait-and-foreign-items.rs:4:5
+   |
+LL |     #[inline]
+   |     ^^^^^^^^^
+LL |     const X: u32;
+   |     ------------- not a function or closure
+
+error[E0518]: attribute should be applied to function or closure
+  --> $DIR/inline-trait-and-foreign-items.rs:7:5
+   |
+LL |     #[inline]
+   |     ^^^^^^^^^
+LL |     type T;
+   |     ------- not a function or closure
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0518`.