about summary refs log tree commit diff
path: root/tests/ui/tool-attributes
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/tool-attributes
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
Move /src/test to /tests
Diffstat (limited to 'tests/ui/tool-attributes')
-rw-r--r--tests/ui/tool-attributes/diagnostic_item.rs3
-rw-r--r--tests/ui/tool-attributes/diagnostic_item.stderr11
-rw-r--r--tests/ui/tool-attributes/diagnostic_item2.rs6
-rw-r--r--tests/ui/tool-attributes/diagnostic_item3.rs7
-rw-r--r--tests/ui/tool-attributes/tool-attributes-misplaced-1.rs18
-rw-r--r--tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr52
-rw-r--r--tests/ui/tool-attributes/tool-attributes-misplaced-2.rs6
-rw-r--r--tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr14
-rw-r--r--tests/ui/tool-attributes/tool-attributes-shadowing.rs4
-rw-r--r--tests/ui/tool-attributes/tool-attributes-shadowing.stderr9
10 files changed, 130 insertions, 0 deletions
diff --git a/tests/ui/tool-attributes/diagnostic_item.rs b/tests/ui/tool-attributes/diagnostic_item.rs
new file mode 100644
index 00000000000..26a52ce60cf
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/diagnostic_item.stderr b/tests/ui/tool-attributes/diagnostic_item.stderr
new file mode 100644
index 00000000000..743e4b658c6
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/diagnostic_item2.rs b/tests/ui/tool-attributes/diagnostic_item2.rs
new file mode 100644
index 00000000000..b32a66b16be
--- /dev/null
+++ b/tests/ui/tool-attributes/diagnostic_item2.rs
@@ -0,0 +1,6 @@
+// check-pass
+
+#[clippy::diagnostic_item = "mep"]
+struct Mep;
+
+fn main() {}
diff --git a/tests/ui/tool-attributes/diagnostic_item3.rs b/tests/ui/tool-attributes/diagnostic_item3.rs
new file mode 100644
index 00000000000..c1a236ed1cc
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs b/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs
new file mode 100644
index 00000000000..bf45ba2ed82
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr
new file mode 100644
index 00000000000..71fd5f1d44a
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-misplaced-2.rs b/tests/ui/tool-attributes/tool-attributes-misplaced-2.rs
new file mode 100644
index 00000000000..b5666e4ea70
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr b/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr
new file mode 100644
index 00000000000..6d0f826e621
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-shadowing.rs b/tests/ui/tool-attributes/tool-attributes-shadowing.rs
new file mode 100644
index 00000000000..21bbaa3a710
--- /dev/null
+++ b/tests/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/tests/ui/tool-attributes/tool-attributes-shadowing.stderr b/tests/ui/tool-attributes/tool-attributes-shadowing.stderr
new file mode 100644
index 00000000000..98ad109a07e
--- /dev/null
+++ b/tests/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`.