diff options
Diffstat (limited to 'src/test')
11 files changed, 955 insertions, 32 deletions
| diff --git a/src/test/ui/parser/fn-arg-doc-comment.rs b/src/test/ui/parser/fn-arg-doc-comment.rs index 22af94b6284..4a4f959e213 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.rs +++ b/src/test/ui/parser/fn-arg-doc-comment.rs @@ -1,20 +1,20 @@ pub fn f( /// Comment - //~^ ERROR documentation comments cannot be applied to method arguments + //~^ ERROR documentation comments cannot be applied to function parameters //~| NOTE doc comments are not allowed here + //~| ERROR attributes on function parameters are unstable + //~| NOTE https://github.com/rust-lang/rust/issues/60406 id: u8, /// Other - //~^ ERROR documentation comments cannot be applied to method arguments + //~^ ERROR documentation comments cannot be applied to function parameters //~| NOTE doc comments are not allowed here + //~| ERROR attributes on function parameters are unstable + //~| NOTE https://github.com/rust-lang/rust/issues/60406 a: u8, ) {} -fn foo(#[allow(dead_code)] id: i32) {} -//~^ ERROR attributes cannot be applied to method arguments -//~| NOTE attributes are not allowed here - fn bar(id: #[allow(dead_code)] i32) {} -//~^ ERROR attributes cannot be applied to a method argument's type +//~^ ERROR attributes cannot be applied to a function parameter's type //~| NOTE attributes are not allowed here fn main() { @@ -26,10 +26,6 @@ fn main() { //~| ERROR mismatched types //~| NOTE expected u8, found reference //~| NOTE expected - foo(""); - //~^ ERROR mismatched types - //~| NOTE expected i32, found reference - //~| NOTE expected bar(""); //~^ ERROR mismatched types //~| NOTE expected i32, found reference diff --git a/src/test/ui/parser/fn-arg-doc-comment.stderr b/src/test/ui/parser/fn-arg-doc-comment.stderr index 73a24eebb3f..9058e88d1d7 100644 --- a/src/test/ui/parser/fn-arg-doc-comment.stderr +++ b/src/test/ui/parser/fn-arg-doc-comment.stderr @@ -1,26 +1,38 @@ -error: documentation comments cannot be applied to method arguments +error: attributes cannot be applied to a function parameter's type + --> $DIR/fn-arg-doc-comment.rs:16:12 + | +LL | fn bar(id: #[allow(dead_code)] i32) {} + | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: documentation comments cannot be applied to function parameters --> $DIR/fn-arg-doc-comment.rs:2:5 | LL | /// Comment | ^^^^^^^^^^^ doc comments are not allowed here -error: documentation comments cannot be applied to method arguments - --> $DIR/fn-arg-doc-comment.rs:6:5 +error: documentation comments cannot be applied to function parameters + --> $DIR/fn-arg-doc-comment.rs:8:5 | LL | /// Other | ^^^^^^^^^ doc comments are not allowed here -error: attributes cannot be applied to method arguments - --> $DIR/fn-arg-doc-comment.rs:12:8 +error[E0658]: attributes on function parameters are unstable + --> $DIR/fn-arg-doc-comment.rs:2:5 + | +LL | /// Comment + | ^^^^^^^^^^^ | -LL | fn foo(#[allow(dead_code)] id: i32) {} - | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here + = note: for more information, see https://github.com/rust-lang/rust/issues/60406 + = help: add #![feature(param_attrs)] to the crate attributes to enable -error: attributes cannot be applied to a method argument's type - --> $DIR/fn-arg-doc-comment.rs:16:12 +error[E0658]: attributes on function parameters are unstable + --> $DIR/fn-arg-doc-comment.rs:8:5 | -LL | fn bar(id: #[allow(dead_code)] i32) {} - | ^^^^^^^^^^^^^^^^^^^ attributes are not allowed here +LL | /// Other + | ^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/60406 + = help: add #![feature(param_attrs)] to the crate attributes to enable error[E0308]: mismatched types --> $DIR/fn-arg-doc-comment.rs:22:7 @@ -43,15 +55,6 @@ LL | f("", ""); error[E0308]: mismatched types --> $DIR/fn-arg-doc-comment.rs:29:9 | -LL | foo(""); - | ^^ expected i32, found reference - | - = note: expected type `i32` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/fn-arg-doc-comment.rs:33:9 - | LL | bar(""); | ^^ expected i32, found reference | @@ -60,4 +63,5 @@ LL | bar(""); error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0308, E0658. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs new file mode 100644 index 00000000000..e900ccab4fd --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs @@ -0,0 +1,8 @@ +// edition:2018 + +#![feature(param_attrs)] + +trait Trait2015 { fn foo(#[allow(C)] i32); } +//~^ ERROR expected one of `:` or `@`, found `)` + +fn main() {} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr new file mode 100644 index 00000000000..d0ed65f2880 --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr @@ -0,0 +1,18 @@ +error: expected one of `:` or `@`, found `)` + --> $DIR/param-attrs-2018.rs:5:41 + | +LL | trait Trait2015 { fn foo(#[allow(C)] i32); } + | ^ expected one of `:` or `@` here + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this was a parameter name, give it a type + | +LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); } + | ^^^^^^^^^^^^^ +help: if this is a type, explicitly ignore the parameter name + | +LL | trait Trait2015 { fn foo(#[allow(C)] _: i32); } + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs new file mode 100644 index 00000000000..c521d04fda5 --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -0,0 +1,225 @@ +// compile-flags: --cfg something +// compile-pass + +#![feature(param_attrs)] + +extern "C" { + fn ffi( + #[allow(C)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[deny(C)] d: i32, + #[forbid(C)] #[warn(C)] ... + ); +} + +type FnType = fn( + #[allow(C)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[deny(C)] d: i32, + #[forbid(C)] #[warn(C)] e: i32 +); + +pub fn foo( + #[allow(C)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[deny(C)] d: i32, + #[forbid(C)] #[warn(C)] e: i32 +) {} + +// self, &self and &mut self + +struct SelfStruct {} +impl SelfStruct { + fn foo( + #[allow(C)] self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} + +struct RefStruct {} +impl RefStruct { + fn foo( + #[allow(C)] &self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait RefTrait { + fn foo( + #[forbid(C)] &self, + #[warn(C)] a: i32 + ) {} +} +impl RefTrait for RefStruct { + fn foo( + #[forbid(C)] &self, + #[warn(C)] a: i32 + ) {} +} + +struct MutStruct {} +impl MutStruct { + fn foo( + #[allow(C)] &mut self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait MutTrait { + fn foo( + #[forbid(C)] &mut self, + #[warn(C)] a: i32 + ) {} +} +impl MutTrait for MutStruct { + fn foo( + #[forbid(C)] &mut self, + #[warn(C)] a: i32 + ) {} +} + +// self: Self, self: &Self and self: &mut Self + +struct NamedSelfSelfStruct {} +impl NamedSelfSelfStruct { + fn foo( + #[allow(C)] self: Self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} + +struct NamedSelfRefStruct {} +impl NamedSelfRefStruct { + fn foo( + #[allow(C)] self: &Self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait NamedSelfRefTrait { + fn foo( + #[forbid(C)] self: &Self, + #[warn(C)] a: i32 + ) {} +} +impl NamedSelfRefTrait for NamedSelfRefStruct { + fn foo( + #[forbid(C)] self: &Self, + #[warn(C)] a: i32 + ) {} +} + +struct NamedSelfMutStruct {} +impl NamedSelfMutStruct { + fn foo( + #[allow(C)] self: &mut Self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait NamedSelfMutTrait { + fn foo( + #[forbid(C)] self: &mut Self, + #[warn(C)] a: i32 + ) {} +} +impl NamedSelfMutTrait for NamedSelfMutStruct { + fn foo( + #[forbid(C)] self: &mut Self, + #[warn(C)] a: i32 + ) {} +} + +// &'a self and &'a mut self + +struct NamedLifetimeRefStruct {} +impl NamedLifetimeRefStruct { + fn foo<'a>( + #[allow(C)] self: &'a Self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait NamedLifetimeRefTrait { + fn foo<'a>( + #[forbid(C)] &'a self, + #[warn(C)] a: i32 + ) {} +} +impl NamedLifetimeRefTrait for NamedLifetimeRefStruct { + fn foo<'a>( + #[forbid(C)] &'a self, + #[warn(C)] a: i32 + ) {} +} + +struct NamedLifetimeMutStruct {} +impl NamedLifetimeMutStruct { + fn foo<'a>( + #[allow(C)] self: &'a mut Self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait NamedLifetimeMutTrait { + fn foo<'a>( + #[forbid(C)] &'a mut self, + #[warn(C)] a: i32 + ) {} +} +impl NamedLifetimeMutTrait for NamedLifetimeMutStruct { + fn foo<'a>( + #[forbid(C)] &'a mut self, + #[warn(C)] a: i32 + ) {} +} + +// Box<Self> + +struct BoxSelfStruct {} +impl BoxSelfStruct { + fn foo( + #[allow(C)] self: Box<Self>, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] b: i32, + ) {} +} +trait BoxSelfTrait { + fn foo( + #[forbid(C)] self: Box<Self>, + #[warn(C)] a: i32 + ) {} +} +impl BoxSelfTrait for BoxSelfStruct { + fn foo( + #[forbid(C)] self: Box<Self>, + #[warn(C)] a: i32 + ) {} +} + +fn main() { + let _: unsafe extern "C" fn(_, _, _, ...) = ffi; + let _: fn(_, _, _, _) = foo; + let _: FnType = |_, _, _, _| {}; + let c = | + #[allow(C)] a: u32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(C)] c: i32, + | {}; + let _ = c(1, 2); +} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs new file mode 100644 index 00000000000..352375729bd --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -0,0 +1,145 @@ +#![feature(param_attrs)] + +extern "C" { + fn ffi( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + ); +} + +type FnType = fn( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in +); + +pub fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in +) {} + +struct SelfStruct {} +impl SelfStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + ) {} +} + +struct RefStruct {} +impl RefStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + ) {} +} +trait RefTrait { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + ) {} +} +impl RefTrait for RefStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + ) {} +} + +fn main() { + let _ = | + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32 + //~^ ERROR allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in + | {}; +} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr new file mode 100644 index 00000000000..e6f3efc04ce --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -0,0 +1,339 @@ +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:5:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:9:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:11:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:13:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:15:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:21:5 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:25:5 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:27:5 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:29:5 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:31:5 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:36:5 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:40:5 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:42:5 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:44:5 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:46:5 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:53:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:56:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:60:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:62:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:64:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:66:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:74:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:77:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:81:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:83:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:85:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:87:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:93:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:96:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:100:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:102:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:104:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:106:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:112:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:115:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:119:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:121:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:123:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:125:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:132:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:136:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:138:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:140:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:142:9 + | +LL | #[no_mangle] b: i32 + | ^^^^^^^^^^^^ + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:7:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:23:5 + | +LL | #[test] a: u32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:38:5 + | +LL | #[test] a: u32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:58:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:79:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:98:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:117:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/param-attrs-builtin-attrs.rs:134:9 + | +LL | #[test] a: u32, + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 52 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs new file mode 100644 index 00000000000..977b5d9ce34 --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -0,0 +1,79 @@ +// compile-flags: --cfg something + +#![feature(param_attrs)] +#![deny(unused_variables)] + +extern "C" { + fn ffi( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[cfg_attr(nothing, cfg(nothing))] ... + ); +} + +type FnType = fn( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(nothing, cfg(nothing))] c: i32, + #[cfg_attr(something, cfg(nothing))] d: i32, +); + +fn foo( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` [unused_variables] + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` [unused_variables] + #[cfg_attr(something, cfg(nothing))] d: i32, +) {} + +struct RefStruct {} +impl RefStruct { + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` [unused_variables] + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` [unused_variables] + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} +trait RefTrait { + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` [unused_variables] + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` [unused_variables] + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} +impl RefTrait for RefStruct { + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` [unused_variables] + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` [unused_variables] + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} + +fn main() { + let _: unsafe extern "C" fn(_, ...) = ffi; + let _: fn(_, _) = foo; + let _: FnType = |_, _| {}; + let c = | + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` [unused_variables] + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` [unused_variables] + #[cfg_attr(something, cfg(nothing))] d: i32, + | {}; + let _ = c(1, 2); +} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr new file mode 100644 index 00000000000..c97190324e5 --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr @@ -0,0 +1,68 @@ +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:24:23 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + | +note: lint level defined here + --> $DIR/param-attrs-cfg.rs:4:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:26:40 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: consider prefixing with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:72:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:74:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: consider prefixing with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:47:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:49:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: consider prefixing with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:36:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:38:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: consider prefixing with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:58:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:60:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: consider prefixing with an underscore: `_c` + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs new file mode 100644 index 00000000000..c5a6514efb0 --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs @@ -0,0 +1,14 @@ +// gate-test-param_attrs + +fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function parameters + //~| NOTE doc comments are not allowed here + //~| ERROR attributes on function parameters are unstable + //~| NOTE https://github.com/rust-lang/rust/issues/60406 + #[allow(C)] a: u8 + //~^ ERROR attributes on function parameters are unstable + //~| NOTE https://github.com/rust-lang/rust/issues/60406 +) {} + +fn main() {} diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr new file mode 100644 index 00000000000..82f21e7fdbc --- /dev/null +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr @@ -0,0 +1,27 @@ +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-feature-gate.rs:4:5 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error[E0658]: attributes on function parameters are unstable + --> $DIR/param-attrs-feature-gate.rs:4:5 + | +LL | /// Foo + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/60406 + = help: add #![feature(param_attrs)] to the crate attributes to enable + +error[E0658]: attributes on function parameters are unstable + --> $DIR/param-attrs-feature-gate.rs:9:5 + | +LL | #[allow(C)] a: u8 + | ^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/60406 + = help: add #![feature(param_attrs)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. | 
