From 9f0e1d4921bbb40fea71594d7c599c09ab513232 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 9 Feb 2021 22:17:10 +0100 Subject: [PATCH] Add attr-on-params test --- src/test/ui/attributes/attrs-on-params.rs | 8 ++++++++ src/test/ui/attributes/attrs-on-params.stderr | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/attributes/attrs-on-params.rs create mode 100644 src/test/ui/attributes/attrs-on-params.stderr diff --git a/src/test/ui/attributes/attrs-on-params.rs b/src/test/ui/attributes/attrs-on-params.rs new file mode 100644 index 00000000000..0e606eac1e8 --- /dev/null +++ b/src/test/ui/attributes/attrs-on-params.rs @@ -0,0 +1,8 @@ +// This checks that incorrect params on function parameters are caught + +fn function(#[inline] param: u32) { + //~^ ERROR attribute should be applied to function or closure + //~| ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes +} + +fn main() {} diff --git a/src/test/ui/attributes/attrs-on-params.stderr b/src/test/ui/attributes/attrs-on-params.stderr new file mode 100644 index 00000000000..003f43d371a --- /dev/null +++ b/src/test/ui/attributes/attrs-on-params.stderr @@ -0,0 +1,17 @@ +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/attrs-on-params.rs:3:13 + | +LL | fn function(#[inline] param: u32) { + | ^^^^^^^^^ + +error[E0518]: attribute should be applied to function or closure + --> $DIR/attrs-on-params.rs:3:13 + | +LL | fn function(#[inline] param: u32) { + | ^^^^^^^^^----------- + | | + | not a function or closure + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0518`.