summaryrefslogtreecommitdiffstats
path: root/tests/ui/malformed
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/malformed')
-rw-r--r--tests/ui/malformed/issue-69341-malformed-derive-inert.rs6
-rw-r--r--tests/ui/malformed/issue-69341-malformed-derive-inert.stderr8
-rw-r--r--tests/ui/malformed/malformed-derive-entry.rs14
-rw-r--r--tests/ui/malformed/malformed-derive-entry.stderr49
-rw-r--r--tests/ui/malformed/malformed-interpolated.rs16
-rw-r--r--tests/ui/malformed/malformed-interpolated.stderr22
-rw-r--r--tests/ui/malformed/malformed-meta-delim.rs11
-rw-r--r--tests/ui/malformed/malformed-meta-delim.stderr24
-rw-r--r--tests/ui/malformed/malformed-plugin-1.rs5
-rw-r--r--tests/ui/malformed/malformed-plugin-1.stderr16
-rw-r--r--tests/ui/malformed/malformed-plugin-2.rs5
-rw-r--r--tests/ui/malformed/malformed-plugin-2.stderr16
-rw-r--r--tests/ui/malformed/malformed-plugin-3.rs5
-rw-r--r--tests/ui/malformed/malformed-plugin-3.stderr17
-rw-r--r--tests/ui/malformed/malformed-regressions.rs12
-rw-r--r--tests/ui/malformed/malformed-regressions.stderr48
-rw-r--r--tests/ui/malformed/malformed-special-attrs.rs13
-rw-r--r--tests/ui/malformed/malformed-special-attrs.stderr30
18 files changed, 317 insertions, 0 deletions
diff --git a/tests/ui/malformed/issue-69341-malformed-derive-inert.rs b/tests/ui/malformed/issue-69341-malformed-derive-inert.rs
new file mode 100644
index 000000000..fc4c3f4e6
--- /dev/null
+++ b/tests/ui/malformed/issue-69341-malformed-derive-inert.rs
@@ -0,0 +1,6 @@
+fn main() {}
+
+struct CLI {
+ #[derive(parse())] //~ ERROR expected non-macro attribute, found attribute macro
+ path: (),
+}
diff --git a/tests/ui/malformed/issue-69341-malformed-derive-inert.stderr b/tests/ui/malformed/issue-69341-malformed-derive-inert.stderr
new file mode 100644
index 000000000..04f7ebe01
--- /dev/null
+++ b/tests/ui/malformed/issue-69341-malformed-derive-inert.stderr
@@ -0,0 +1,8 @@
+error: expected non-macro attribute, found attribute macro `derive`
+ --> $DIR/issue-69341-malformed-derive-inert.rs:4:7
+ |
+LL | #[derive(parse())]
+ | ^^^^^^ not a non-macro attribute
+
+error: aborting due to previous error
+
diff --git a/tests/ui/malformed/malformed-derive-entry.rs b/tests/ui/malformed/malformed-derive-entry.rs
new file mode 100644
index 000000000..77fa2f566
--- /dev/null
+++ b/tests/ui/malformed/malformed-derive-entry.rs
@@ -0,0 +1,14 @@
+#[derive(Copy(Bad))]
+//~^ ERROR traits in `#[derive(...)]` don't accept arguments
+//~| ERROR the trait bound
+struct Test1;
+
+#[derive(Copy="bad")]
+//~^ ERROR traits in `#[derive(...)]` don't accept values
+//~| ERROR the trait bound
+struct Test2;
+
+#[derive] //~ ERROR malformed `derive` attribute input
+struct Test4;
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-derive-entry.stderr b/tests/ui/malformed/malformed-derive-entry.stderr
new file mode 100644
index 000000000..6ff6fbabb
--- /dev/null
+++ b/tests/ui/malformed/malformed-derive-entry.stderr
@@ -0,0 +1,49 @@
+error: traits in `#[derive(...)]` don't accept arguments
+ --> $DIR/malformed-derive-entry.rs:1:14
+ |
+LL | #[derive(Copy(Bad))]
+ | ^^^^^ help: remove the arguments
+
+error: traits in `#[derive(...)]` don't accept values
+ --> $DIR/malformed-derive-entry.rs:6:14
+ |
+LL | #[derive(Copy="bad")]
+ | ^^^^^^ help: remove the value
+
+error: malformed `derive` attribute input
+ --> $DIR/malformed-derive-entry.rs:11:1
+ |
+LL | #[derive]
+ | ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
+
+error[E0277]: the trait bound `Test1: Clone` is not satisfied
+ --> $DIR/malformed-derive-entry.rs:1:10
+ |
+LL | #[derive(Copy(Bad))]
+ | ^^^^ the trait `Clone` is not implemented for `Test1`
+ |
+note: required by a bound in `Copy`
+ --> $SRC_DIR/core/src/marker.rs:LL:COL
+ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider annotating `Test1` with `#[derive(Clone)]`
+ |
+LL | #[derive(Clone)]
+ |
+
+error[E0277]: the trait bound `Test2: Clone` is not satisfied
+ --> $DIR/malformed-derive-entry.rs:6:10
+ |
+LL | #[derive(Copy="bad")]
+ | ^^^^ the trait `Clone` is not implemented for `Test2`
+ |
+note: required by a bound in `Copy`
+ --> $SRC_DIR/core/src/marker.rs:LL:COL
+ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider annotating `Test2` with `#[derive(Clone)]`
+ |
+LL | #[derive(Clone)]
+ |
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/malformed/malformed-interpolated.rs b/tests/ui/malformed/malformed-interpolated.rs
new file mode 100644
index 000000000..0d84e723f
--- /dev/null
+++ b/tests/ui/malformed/malformed-interpolated.rs
@@ -0,0 +1,16 @@
+#![feature(rustc_attrs)]
+
+macro_rules! check {
+ ($expr: expr) => (
+ #[rustc_dummy = $expr]
+ use main as _;
+ );
+}
+
+check!("0"); // OK
+check!(0); // OK
+check!(0u8); //~ ERROR suffixed literals are not allowed in attributes
+check!(-0); //~ ERROR unexpected expression: `-0`
+check!(0 + 0); //~ ERROR unexpected expression: `0 + 0`
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-interpolated.stderr b/tests/ui/malformed/malformed-interpolated.stderr
new file mode 100644
index 000000000..c24d9f153
--- /dev/null
+++ b/tests/ui/malformed/malformed-interpolated.stderr
@@ -0,0 +1,22 @@
+error: suffixed literals are not allowed in attributes
+ --> $DIR/malformed-interpolated.rs:12:8
+ |
+LL | check!(0u8);
+ | ^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: unexpected expression: `-0`
+ --> $DIR/malformed-interpolated.rs:13:8
+ |
+LL | check!(-0);
+ | ^^
+
+error: unexpected expression: `0 + 0`
+ --> $DIR/malformed-interpolated.rs:14:8
+ |
+LL | check!(0 + 0);
+ | ^^^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/malformed/malformed-meta-delim.rs b/tests/ui/malformed/malformed-meta-delim.rs
new file mode 100644
index 000000000..5b1614b69
--- /dev/null
+++ b/tests/ui/malformed/malformed-meta-delim.rs
@@ -0,0 +1,11 @@
+fn main() {}
+
+#[allow { foo_lint } ]
+//~^ ERROR wrong meta list delimiters
+//~| HELP the delimiters should be `(` and `)`
+fn delim_brace() {}
+
+#[allow [ foo_lint ] ]
+//~^ ERROR wrong meta list delimiters
+//~| HELP the delimiters should be `(` and `)`
+fn delim_bracket() {}
diff --git a/tests/ui/malformed/malformed-meta-delim.stderr b/tests/ui/malformed/malformed-meta-delim.stderr
new file mode 100644
index 000000000..27636c3d5
--- /dev/null
+++ b/tests/ui/malformed/malformed-meta-delim.stderr
@@ -0,0 +1,24 @@
+error: wrong meta list delimiters
+ --> $DIR/malformed-meta-delim.rs:3:9
+ |
+LL | #[allow { foo_lint } ]
+ | ^^^^^^^^^^^^
+ |
+help: the delimiters should be `(` and `)`
+ |
+LL | #[allow ( foo_lint ) ]
+ | ~ ~
+
+error: wrong meta list delimiters
+ --> $DIR/malformed-meta-delim.rs:8:9
+ |
+LL | #[allow [ foo_lint ] ]
+ | ^^^^^^^^^^^^
+ |
+help: the delimiters should be `(` and `)`
+ |
+LL | #[allow ( foo_lint ) ]
+ | ~ ~
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/malformed/malformed-plugin-1.rs b/tests/ui/malformed/malformed-plugin-1.rs
new file mode 100644
index 000000000..d4c1a2a16
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-1.rs
@@ -0,0 +1,5 @@
+#![feature(plugin)]
+#![plugin] //~ ERROR malformed `plugin` attribute
+//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-plugin-1.stderr b/tests/ui/malformed/malformed-plugin-1.stderr
new file mode 100644
index 000000000..505f6b6f1
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-1.stderr
@@ -0,0 +1,16 @@
+error: malformed `plugin` attribute input
+ --> $DIR/malformed-plugin-1.rs:2:1
+ |
+LL | #![plugin]
+ | ^^^^^^^^^^ help: must be of the form: `#![plugin(name)]`
+
+warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
+ --> $DIR/malformed-plugin-1.rs:2:1
+ |
+LL | #![plugin]
+ | ^^^^^^^^^^ help: may be removed in a future compiler version
+ |
+ = note: `#[warn(deprecated)]` on by default
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/malformed/malformed-plugin-2.rs b/tests/ui/malformed/malformed-plugin-2.rs
new file mode 100644
index 000000000..ba80d97a3
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-2.rs
@@ -0,0 +1,5 @@
+#![feature(plugin)]
+#![plugin="bleh"] //~ ERROR malformed `plugin` attribute
+//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-plugin-2.stderr b/tests/ui/malformed/malformed-plugin-2.stderr
new file mode 100644
index 000000000..52bbd82a3
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-2.stderr
@@ -0,0 +1,16 @@
+error: malformed `plugin` attribute input
+ --> $DIR/malformed-plugin-2.rs:2:1
+ |
+LL | #![plugin="bleh"]
+ | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#![plugin(name)]`
+
+warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
+ --> $DIR/malformed-plugin-2.rs:2:1
+ |
+LL | #![plugin="bleh"]
+ | ^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
+ |
+ = note: `#[warn(deprecated)]` on by default
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/malformed/malformed-plugin-3.rs b/tests/ui/malformed/malformed-plugin-3.rs
new file mode 100644
index 000000000..d2bd8f9f8
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-3.rs
@@ -0,0 +1,5 @@
+#![feature(plugin)]
+#![plugin(foo="bleh")] //~ ERROR malformed `plugin` attribute
+//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-plugin-3.stderr b/tests/ui/malformed/malformed-plugin-3.stderr
new file mode 100644
index 000000000..64cb429ea
--- /dev/null
+++ b/tests/ui/malformed/malformed-plugin-3.stderr
@@ -0,0 +1,17 @@
+error[E0498]: malformed `plugin` attribute
+ --> $DIR/malformed-plugin-3.rs:2:11
+ |
+LL | #![plugin(foo="bleh")]
+ | ^^^^^^^^^^ malformed attribute
+
+warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
+ --> $DIR/malformed-plugin-3.rs:2:1
+ |
+LL | #![plugin(foo="bleh")]
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
+ |
+ = note: `#[warn(deprecated)]` on by default
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0498`.
diff --git a/tests/ui/malformed/malformed-regressions.rs b/tests/ui/malformed/malformed-regressions.rs
new file mode 100644
index 000000000..ac1444bba
--- /dev/null
+++ b/tests/ui/malformed/malformed-regressions.rs
@@ -0,0 +1,12 @@
+#[doc] //~ ERROR attribute must be of the form
+//~^ WARN this was previously accepted
+#[ignore()] //~ ERROR attribute must be of the form
+//~^ WARN this was previously accepted
+#[inline = ""] //~ ERROR attribute must be of the form
+//~^ WARN this was previously accepted
+#[link] //~ ERROR attribute must be of the form
+//~^ WARN this was previously accepted
+#[link = ""] //~ ERROR attribute must be of the form
+//~^ WARN this was previously accepted
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-regressions.stderr b/tests/ui/malformed/malformed-regressions.stderr
new file mode 100644
index 000000000..9bfbe7eba
--- /dev/null
+++ b/tests/ui/malformed/malformed-regressions.stderr
@@ -0,0 +1,48 @@
+error: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]`
+ --> $DIR/malformed-regressions.rs:1:1
+ |
+LL | #[doc]
+ | ^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
+ = note: `#[deny(ill_formed_attribute_input)]` on by default
+
+error: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]`
+ --> $DIR/malformed-regressions.rs:3:1
+ |
+LL | #[ignore()]
+ | ^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
+
+error: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
+ --> $DIR/malformed-regressions.rs:5:1
+ |
+LL | #[inline = ""]
+ | ^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
+
+error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]`
+ --> $DIR/malformed-regressions.rs:7:1
+ |
+LL | #[link]
+ | ^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
+
+error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]`
+ --> $DIR/malformed-regressions.rs:9:1
+ |
+LL | #[link = ""]
+ | ^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
+
+error: aborting due to 5 previous errors
+
diff --git a/tests/ui/malformed/malformed-special-attrs.rs b/tests/ui/malformed/malformed-special-attrs.rs
new file mode 100644
index 000000000..05b7ebe46
--- /dev/null
+++ b/tests/ui/malformed/malformed-special-attrs.rs
@@ -0,0 +1,13 @@
+#[cfg_attr] //~ ERROR malformed `cfg_attr` attribute
+struct S1;
+
+#[cfg_attr = ""] //~ ERROR malformed `cfg_attr` attribute
+struct S2;
+
+#[derive] //~ ERROR malformed `derive` attribute
+struct S3;
+
+#[derive = ""] //~ ERROR malformed `derive` attribute
+struct S4;
+
+fn main() {}
diff --git a/tests/ui/malformed/malformed-special-attrs.stderr b/tests/ui/malformed/malformed-special-attrs.stderr
new file mode 100644
index 000000000..1764c3969
--- /dev/null
+++ b/tests/ui/malformed/malformed-special-attrs.stderr
@@ -0,0 +1,30 @@
+error: malformed `cfg_attr` attribute input
+ --> $DIR/malformed-special-attrs.rs:1:1
+ |
+LL | #[cfg_attr]
+ | ^^^^^^^^^^^ help: missing condition and attribute: `#[cfg_attr(condition, attribute, other_attribute, ...)]`
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
+
+error: malformed `cfg_attr` attribute input
+ --> $DIR/malformed-special-attrs.rs:4:1
+ |
+LL | #[cfg_attr = ""]
+ | ^^^^^^^^^^^^^^^^ help: missing condition and attribute: `#[cfg_attr(condition, attribute, other_attribute, ...)]`
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
+
+error: malformed `derive` attribute input
+ --> $DIR/malformed-special-attrs.rs:7:1
+ |
+LL | #[derive]
+ | ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
+
+error: malformed `derive` attribute input
+ --> $DIR/malformed-special-attrs.rs:10:1
+ |
+LL | #[derive = ""]
+ | ^^^^^^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]`
+
+error: aborting due to 4 previous errors
+