summaryrefslogtreecommitdiffstats
path: root/src/test/ui/tool-attributes
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/tool-attributes')
-rw-r--r--src/test/ui/tool-attributes/diagnostic_item.rs3
-rw-r--r--src/test/ui/tool-attributes/diagnostic_item.stderr11
-rw-r--r--src/test/ui/tool-attributes/diagnostic_item2.rs6
-rw-r--r--src/test/ui/tool-attributes/diagnostic_item3.rs7
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs18
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr52
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-misplaced-2.rs6
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-misplaced-2.stderr14
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-shadowing.rs4
-rw-r--r--src/test/ui/tool-attributes/tool-attributes-shadowing.stderr9
10 files changed, 130 insertions, 0 deletions
diff --git a/src/test/ui/tool-attributes/diagnostic_item.rs b/src/test/ui/tool-attributes/diagnostic_item.rs
new file mode 100644
index 000000000..26a52ce60
--- /dev/null
+++ b/src/test/ui/tool-attributes/diagnostic_item.rs
@@ -0,0 +1,3 @@
+#[rustc_diagnostic_item = "foomp"] //~ ERROR compiler internal support for linting
+struct Foomp;
+fn main() {}
diff --git a/src/test/ui/tool-attributes/diagnostic_item.stderr b/src/test/ui/tool-attributes/diagnostic_item.stderr
new file mode 100644
index 000000000..743e4b658
--- /dev/null
+++ b/src/test/ui/tool-attributes/diagnostic_item.stderr
@@ -0,0 +1,11 @@
+error[E0658]: diagnostic items compiler internal support for linting
+ --> $DIR/diagnostic_item.rs:1:1
+ |
+LL | #[rustc_diagnostic_item = "foomp"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/tool-attributes/diagnostic_item2.rs b/src/test/ui/tool-attributes/diagnostic_item2.rs
new file mode 100644
index 000000000..b32a66b16
--- /dev/null
+++ b/src/test/ui/tool-attributes/diagnostic_item2.rs
@@ -0,0 +1,6 @@
+// check-pass
+
+#[clippy::diagnostic_item = "mep"]
+struct Mep;
+
+fn main() {}
diff --git a/src/test/ui/tool-attributes/diagnostic_item3.rs b/src/test/ui/tool-attributes/diagnostic_item3.rs
new file mode 100644
index 000000000..c1a236ed1
--- /dev/null
+++ b/src/test/ui/tool-attributes/diagnostic_item3.rs
@@ -0,0 +1,7 @@
+// check-pass
+#![feature(rustc_attrs)]
+
+#[rustc_diagnostic_item = "foomp"]
+struct Foomp;
+
+fn main() {}
diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs
new file mode 100644
index 000000000..bf45ba2ed
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs
@@ -0,0 +1,18 @@
+type A = rustfmt; //~ ERROR expected type, found tool module `rustfmt`
+type B = rustfmt::skip; //~ ERROR expected type, found tool attribute `rustfmt::skip`
+
+#[derive(rustfmt)] //~ ERROR cannot find derive macro `rustfmt` in this scope
+ //~| ERROR cannot find derive macro `rustfmt` in this scope
+struct S;
+
+// Interpreted as an unstable custom attribute
+#[rustfmt] //~ ERROR cannot find attribute `rustfmt` in this scope
+fn check() {}
+
+#[rustfmt::skip] // OK
+fn main() {
+ rustfmt; //~ ERROR expected value, found tool module `rustfmt`
+ rustfmt!(); //~ ERROR cannot find macro `rustfmt` in this scope
+
+ rustfmt::skip; //~ ERROR expected value, found tool attribute `rustfmt::skip`
+}
diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr
new file mode 100644
index 000000000..71fd5f1d4
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr
@@ -0,0 +1,52 @@
+error: cannot find derive macro `rustfmt` in this scope
+ --> $DIR/tool-attributes-misplaced-1.rs:4:10
+ |
+LL | #[derive(rustfmt)]
+ | ^^^^^^^
+
+error: cannot find derive macro `rustfmt` in this scope
+ --> $DIR/tool-attributes-misplaced-1.rs:4:10
+ |
+LL | #[derive(rustfmt)]
+ | ^^^^^^^
+
+error: cannot find attribute `rustfmt` in this scope
+ --> $DIR/tool-attributes-misplaced-1.rs:9:3
+ |
+LL | #[rustfmt]
+ | ^^^^^^^
+
+error: cannot find macro `rustfmt` in this scope
+ --> $DIR/tool-attributes-misplaced-1.rs:15:5
+ |
+LL | rustfmt!();
+ | ^^^^^^^
+
+error[E0573]: expected type, found tool module `rustfmt`
+ --> $DIR/tool-attributes-misplaced-1.rs:1:10
+ |
+LL | type A = rustfmt;
+ | ^^^^^^^ not a type
+
+error[E0573]: expected type, found tool attribute `rustfmt::skip`
+ --> $DIR/tool-attributes-misplaced-1.rs:2:10
+ |
+LL | type B = rustfmt::skip;
+ | ^^^^^^^^^^^^^ not a type
+
+error[E0423]: expected value, found tool module `rustfmt`
+ --> $DIR/tool-attributes-misplaced-1.rs:14:5
+ |
+LL | rustfmt;
+ | ^^^^^^^ not a value
+
+error[E0423]: expected value, found tool attribute `rustfmt::skip`
+ --> $DIR/tool-attributes-misplaced-1.rs:17:5
+ |
+LL | rustfmt::skip;
+ | ^^^^^^^^^^^^^ not a value
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0423, E0573.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-2.rs b/src/test/ui/tool-attributes/tool-attributes-misplaced-2.rs
new file mode 100644
index 000000000..b5666e4ea
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-2.rs
@@ -0,0 +1,6 @@
+#[derive(rustfmt::skip)] //~ ERROR expected derive macro, found tool attribute `rustfmt::skip`
+struct S;
+
+fn main() {
+ rustfmt::skip!(); //~ ERROR expected macro, found tool attribute `rustfmt::skip`
+}
diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-2.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-2.stderr
new file mode 100644
index 000000000..6d0f826e6
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-2.stderr
@@ -0,0 +1,14 @@
+error: expected derive macro, found tool attribute `rustfmt::skip`
+ --> $DIR/tool-attributes-misplaced-2.rs:1:10
+ |
+LL | #[derive(rustfmt::skip)]
+ | ^^^^^^^^^^^^^ not a derive macro
+
+error: expected macro, found tool attribute `rustfmt::skip`
+ --> $DIR/tool-attributes-misplaced-2.rs:5:5
+ |
+LL | rustfmt::skip!();
+ | ^^^^^^^^^^^^^ not a macro
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/tool-attributes/tool-attributes-shadowing.rs b/src/test/ui/tool-attributes/tool-attributes-shadowing.rs
new file mode 100644
index 000000000..21bbaa3a7
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-shadowing.rs
@@ -0,0 +1,4 @@
+mod rustfmt {}
+
+#[rustfmt::skip] //~ ERROR failed to resolve: could not find `skip` in `rustfmt`
+fn main() {}
diff --git a/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr b/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr
new file mode 100644
index 000000000..98ad109a0
--- /dev/null
+++ b/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: could not find `skip` in `rustfmt`
+ --> $DIR/tool-attributes-shadowing.rs:3:12
+ |
+LL | #[rustfmt::skip]
+ | ^^^^ could not find `skip` in `rustfmt`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.