diff options
| author | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
| commit | c7312fe4ff85ada30103cea58db25d83e0bec4b0 (patch) | |
| tree | c45aed285c4e04591ea7d6e8bc6c90b3461671a6 /src/test | |
| parent | 4560cb830fce63fcffdc4558f4281aaac6a3a1ba (diff) | |
| parent | 29c377882f545e24b9cc6e1198ee4f72c20d5449 (diff) | |
Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centril
Rollup of 8 pull requests Successful merges: - #61856 (Lint attributes on function arguments) - #62360 (Document that ManuallyDrop::drop should not called more than once) - #62392 (Update minifier-rs version) - #62871 (Explicit error message for async recursion.) - #62995 (Avoid ICE when suggestion span is at Eof) - #63053 (SystemTime docs: recommend Instant for elapsed time) - #63081 (tidy: Cleanup the directory whitelist) - #63088 (Remove anonymous_parameters from unrelated test) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/async-await/recursive-async-impl-trait-type.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/lint/lint-unused-mut-variables.rs | 64 | ||||
| -rw-r--r-- | src/test/ui/lint/lint-unused-mut-variables.stderr | 112 | ||||
| -rw-r--r-- | src/test/ui/lint/lint-unused-variables.rs | 64 | ||||
| -rw-r--r-- | src/test/ui/lint/lint-unused-variables.stderr | 56 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/issue-38371.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-62973.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-62973.stderr | 61 | ||||
| -rw-r--r-- | src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs | 179 | ||||
| -rw-r--r-- | src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs | 40 | ||||
| -rw-r--r-- | src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr | 46 | ||||
| -rw-r--r-- | src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/rfc-2565-param-attrs/param-attrs-feature-gate.stderr | 10 |
14 files changed, 444 insertions, 216 deletions
diff --git a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr index 69914b6a791..64f6eccd547 100644 --- a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr +++ b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr @@ -1,11 +1,11 @@ -error[E0720]: opaque type expands to a recursive type +error[E0733]: recursion in an `async fn` requires boxing --> $DIR/recursive-async-impl-trait-type.rs:7:40 | LL | async fn recursive_async_function() -> () { - | ^^ expands to a recursive type + | ^^ an `async fn` cannot invoke itself directly | - = note: expanded type is `std::future::GenFuture<[static generator@$DIR/recursive-async-impl-trait-type.rs:7:43: 9:2 {impl std::future::Future, ()}]>` + = note: a recursive `async fn` must be rewritten to return a boxed future. error: aborting due to previous error -For more information about this error, try `rustc --explain E0720`. +For more information about this error, try `rustc --explain E0733`. diff --git a/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs b/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs index 4e85bcc4ba6..141f363694a 100644 --- a/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs +++ b/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs @@ -9,7 +9,7 @@ pub trait LolInto<T>: Sized { } pub trait LolFrom<T> { - fn from(T) -> Self; + fn from(_: T) -> Self; } impl<'a, T: ?Sized, U> LolInto<U> for &'a T where T: LolTo<U> { diff --git a/src/test/ui/lint/lint-unused-mut-variables.rs b/src/test/ui/lint/lint-unused-mut-variables.rs index 78609a6e24b..2957f931110 100644 --- a/src/test/ui/lint/lint-unused-mut-variables.rs +++ b/src/test/ui/lint/lint-unused-mut-variables.rs @@ -1,12 +1,70 @@ +// edition:2018 + // Exercise the unused_mut attribute in some positive and negative cases -#![allow(unused_assignments)] -#![allow(unused_variables)] -#![allow(dead_code)] #![deny(unused_mut)] +#![feature(async_await, async_closure, param_attrs)] + +async fn baz_async( + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, +) {} +fn baz( + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + #[allow(unused_mut)] (mut c, d): (i32, i32) +) {} + +struct RefStruct {} +impl RefStruct { + async fn baz_async( + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + ) {} + fn baz( + &self, + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + #[allow(unused_mut)] (mut c, d): (i32, i32) + ) {} +} +trait RefTrait { + fn baz( + &self, + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + #[allow(unused_mut)] (mut c, d): (i32, i32) + ) {} +} +impl RefTrait for () { + fn baz( + &self, + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + #[allow(unused_mut)] (mut c, d): (i32, i32) + ) {} +} fn main() { + let _ = async move | + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + | {}; + let _ = | + mut a: i32, + //~^ ERROR: variable does not need to be mutable + #[allow(unused_mut)] mut b: i32, + #[allow(unused_mut)] (mut c, d): (i32, i32) + | {}; + // negative cases let mut a = 3; //~ ERROR: variable does not need to be mutable diff --git a/src/test/ui/lint/lint-unused-mut-variables.stderr b/src/test/ui/lint/lint-unused-mut-variables.stderr index 1a175c9683e..92c2b68652d 100644 --- a/src/test/ui/lint/lint-unused-mut-variables.stderr +++ b/src/test/ui/lint/lint-unused-mut-variables.stderr @@ -1,19 +1,83 @@ error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:46:14 + --> $DIR/lint-unused-mut-variables.rs:9:5 | -LL | let x = |mut y: isize| 10; - | ----^ - | | - | help: remove this `mut` +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` | note: lint level defined here - --> $DIR/lint-unused-mut-variables.rs:6:9 + --> $DIR/lint-unused-mut-variables.rs:5:9 | LL | #![deny(unused_mut)] | ^^^^^^^^^^ error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:11:9 + --> $DIR/lint-unused-mut-variables.rs:14:5 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:23:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:29:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:39:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:48:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:57:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:62:9 + | +LL | mut a: i32, + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:104:14 + | +LL | let x = |mut y: isize| 10; + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:69:9 | LL | let mut a = 3; | ----^ @@ -21,7 +85,7 @@ LL | let mut a = 3; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:13:9 + --> $DIR/lint-unused-mut-variables.rs:71:9 | LL | let mut a = 2; | ----^ @@ -29,7 +93,7 @@ LL | let mut a = 2; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:15:9 + --> $DIR/lint-unused-mut-variables.rs:73:9 | LL | let mut b = 3; | ----^ @@ -37,7 +101,7 @@ LL | let mut b = 3; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:17:9 + --> $DIR/lint-unused-mut-variables.rs:75:9 | LL | let mut a = vec![3]; | ----^ @@ -45,7 +109,7 @@ LL | let mut a = vec![3]; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:19:10 + --> $DIR/lint-unused-mut-variables.rs:77:10 | LL | let (mut a, b) = (1, 2); | ----^ @@ -53,7 +117,7 @@ LL | let (mut a, b) = (1, 2); | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:21:9 + --> $DIR/lint-unused-mut-variables.rs:79:9 | LL | let mut a; | ----^ @@ -61,7 +125,7 @@ LL | let mut a; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:25:9 + --> $DIR/lint-unused-mut-variables.rs:83:9 | LL | let mut b; | ----^ @@ -69,7 +133,7 @@ LL | let mut b; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:34:9 + --> $DIR/lint-unused-mut-variables.rs:92:9 | LL | mut x => {} | ----^ @@ -77,7 +141,7 @@ LL | mut x => {} | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:38:8 + --> $DIR/lint-unused-mut-variables.rs:96:8 | LL | (mut x, 1) | | ----^ @@ -85,7 +149,7 @@ LL | (mut x, 1) | | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:51:9 + --> $DIR/lint-unused-mut-variables.rs:109:9 | LL | let mut a = &mut 5; | ----^ @@ -93,7 +157,7 @@ LL | let mut a = &mut 5; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:56:9 + --> $DIR/lint-unused-mut-variables.rs:114:9 | LL | let mut b = (&mut a,); | ----^ @@ -101,7 +165,7 @@ LL | let mut b = (&mut a,); | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:59:9 + --> $DIR/lint-unused-mut-variables.rs:117:9 | LL | let mut x = &mut 1; | ----^ @@ -109,7 +173,7 @@ LL | let mut x = &mut 1; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:71:9 + --> $DIR/lint-unused-mut-variables.rs:129:9 | LL | let mut v : &mut Vec<()> = &mut vec![]; | ----^ @@ -117,7 +181,7 @@ LL | let mut v : &mut Vec<()> = &mut vec![]; | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:48:13 + --> $DIR/lint-unused-mut-variables.rs:106:13 | LL | fn what(mut foo: isize) {} | ----^^^ @@ -125,7 +189,7 @@ LL | fn what(mut foo: isize) {} | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:66:20 + --> $DIR/lint-unused-mut-variables.rs:124:20 | LL | fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { | ----^^^ @@ -133,7 +197,7 @@ LL | fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { | help: remove this `mut` error: variable does not need to be mutable - --> $DIR/lint-unused-mut-variables.rs:138:9 + --> $DIR/lint-unused-mut-variables.rs:196:9 | LL | let mut b = vec![2]; | ----^ @@ -141,10 +205,10 @@ LL | let mut b = vec![2]; | help: remove this `mut` | note: lint level defined here - --> $DIR/lint-unused-mut-variables.rs:134:8 + --> $DIR/lint-unused-mut-variables.rs:192:8 | LL | #[deny(unused_mut)] | ^^^^^^^^^^ -error: aborting due to 17 previous errors +error: aborting due to 25 previous errors diff --git a/src/test/ui/lint/lint-unused-variables.rs b/src/test/ui/lint/lint-unused-variables.rs new file mode 100644 index 00000000000..a1660d23511 --- /dev/null +++ b/src/test/ui/lint/lint-unused-variables.rs @@ -0,0 +1,64 @@ +// compile-flags: --cfg something +// edition:2018 + +#![feature(async_await, async_closure, param_attrs)] +#![deny(unused_variables)] + +async fn foo_async( + a: i32, + //~^ ERROR unused variable: `a` + #[allow(unused_variables)] b: i32, +) {} +fn foo( + #[allow(unused_variables)] a: i32, + b: i32, + //~^ ERROR unused variable: `b` +) {} + +struct RefStruct {} +impl RefStruct { + async fn bar_async( + &self, + a: i32, + //~^ ERROR unused variable: `a` + #[allow(unused_variables)] b: i32, + ) {} + fn bar( + &self, + #[allow(unused_variables)] a: i32, + b: i32, + //~^ ERROR unused variable: `b` + ) {} +} +trait RefTrait { + fn bar( + &self, + #[allow(unused_variables)] a: i32, + b: i32, + //~^ ERROR unused variable: `b` + ) {} +} +impl RefTrait for RefStruct { + fn bar( + &self, + #[allow(unused_variables)] a: i32, + b: i32, + //~^ ERROR unused variable: `b` + ) {} +} + +fn main() { + let _: fn(_, _) = foo; + let a = async move | + a: i32, + //~^ ERROR unused variable: `a` + #[allow(unused_variables)] b: i32, + | {}; + let b = | + #[allow(unused_variables)] a: i32, + b: i32, + //~^ ERROR unused variable: `b` + | {}; + let _ = a(1, 2); + let _ = b(1, 2); +} diff --git a/src/test/ui/lint/lint-unused-variables.stderr b/src/test/ui/lint/lint-unused-variables.stderr new file mode 100644 index 00000000000..7ed5669e33c --- /dev/null +++ b/src/test/ui/lint/lint-unused-variables.stderr @@ -0,0 +1,56 @@ +error: unused variable: `a` + --> $DIR/lint-unused-variables.rs:8:5 + | +LL | a: i32, + | ^ help: consider prefixing with an underscore: `_a` + | +note: lint level defined here + --> $DIR/lint-unused-variables.rs:5:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:14:5 + | +LL | b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `a` + --> $DIR/lint-unused-variables.rs:53:9 + | +LL | a: i32, + | ^ help: consider prefixing with an underscore: `_a` + +error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:59:9 + | +LL | b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:37:9 + | +LL | b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `a` + --> $DIR/lint-unused-variables.rs:22:9 + | +LL | a: i32, + | ^ help: consider prefixing with an underscore: `_a` + +error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:29:9 + | +LL | b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:45:9 + | +LL | b: i32, + | ^ help: consider prefixing with an underscore: `_b` + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/mismatched_types/issue-38371.stderr b/src/test/ui/mismatched_types/issue-38371.stderr index a9347926bda..79a0807c337 100644 --- a/src/test/ui/mismatched_types/issue-38371.stderr +++ b/src/test/ui/mismatched_types/issue-38371.stderr @@ -2,11 +2,13 @@ error[E0308]: mismatched types --> $DIR/issue-38371.rs:4:8 | LL | fn foo(&foo: Foo) { - | ^^^^ expected struct `Foo`, found reference + | ^^^^------ + | | + | expected struct `Foo`, found reference + | help: did you mean `foo`: `&Foo` | = note: expected type `Foo` found type `&_` - = help: did you mean `foo: &Foo`? error[E0308]: mismatched types --> $DIR/issue-38371.rs:18:9 diff --git a/src/test/ui/parser/issue-62973.rs b/src/test/ui/parser/issue-62973.rs new file mode 100644 index 00000000000..18bc51e7ba7 --- /dev/null +++ b/src/test/ui/parser/issue-62973.rs @@ -0,0 +1,8 @@ +// ignore-tidy-trailing-newlines +// error-pattern: aborting due to 6 previous errors + +fn main() {} + +fn p() { match s { v, E { [) {) } + + diff --git a/src/test/ui/parser/issue-62973.stderr b/src/test/ui/parser/issue-62973.stderr new file mode 100644 index 00000000000..141076bf6b6 --- /dev/null +++ b/src/test/ui/parser/issue-62973.stderr @@ -0,0 +1,61 @@ +error: this file contains an un-closed delimiter + --> $DIR/issue-62973.rs:8:2 + | +LL | fn p() { match s { v, E { [) {) } + | - - un-closed delimiter + | | + | un-closed delimiter +LL | +LL | + | ^ + +error: expected one of `,` or `}`, found `{` + --> $DIR/issue-62973.rs:6:25 + | +LL | fn p() { match s { v, E { [) {) } + | - ^ expected one of `,` or `}` here + | | + | while parsing this struct + +error: struct literals are not allowed here + --> $DIR/issue-62973.rs:6:16 + | +LL | fn p() { match s { v, E { [) {) } + | ________________^ +LL | | +LL | | + | |_^ +help: surround the struct literal with parentheses + | +LL | fn p() { match (s { v, E { [) {) } +LL | +LL | ) + | + +error: expected one of `.`, `?`, `{`, or an operator, found `}` + --> $DIR/issue-62973.rs:8:1 + | +LL | fn p() { match s { v, E { [) {) } + | ----- while parsing this match expression +LL | +LL | + | ^ expected one of `.`, `?`, `{`, or an operator here + +error: incorrect close delimiter: `)` + --> $DIR/issue-62973.rs:6:28 + | +LL | fn p() { match s { v, E { [) {) } + | -^ incorrect close delimiter + | | + | un-closed delimiter + +error: incorrect close delimiter: `)` + --> $DIR/issue-62973.rs:6:31 + | +LL | fn p() { match s { v, E { [) {) } + | -^ incorrect close delimiter + | | + | un-closed delimiter + +error: aborting due to 6 previous errors + 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 index e796e37bbaa..5eeda66173d 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -1,189 +1,66 @@ +// check-pass // compile-flags: --cfg something -// build-pass (FIXME(62277): could be check-pass?) +#![deny(unused_mut)] #![feature(param_attrs)] extern "C" { fn ffi( - #[allow(C)] a: i32, + #[allow(unused_mut)] a: i32, #[cfg(something)] b: i32, #[cfg_attr(something, cfg(nothing))] c: i32, - #[deny(C)] d: i32, - #[forbid(C)] #[warn(C)] ... + #[deny(unused_mut)] d: i32, + #[forbid(unused_mut)] #[warn(unused_mut)] ... ); } type FnType = fn( - #[allow(C)] a: i32, + #[allow(unused_mut)] a: i32, #[cfg(something)] b: i32, #[cfg_attr(something, cfg(nothing))] c: i32, - #[deny(C)] d: i32, - #[forbid(C)] #[warn(C)] e: i32 + #[deny(unused_mut)] d: i32, + #[forbid(unused_mut)] #[warn(unused_mut)] e: i32 ); pub fn foo( - #[allow(C)] a: i32, + #[allow(unused_mut)] a: i32, #[cfg(something)] b: i32, #[cfg_attr(something, cfg(nothing))] c: i32, - #[deny(C)] d: i32, - #[forbid(C)] #[warn(C)] e: i32 + #[deny(unused_mut)] d: i32, + #[forbid(unused_mut)] #[warn(unused_mut)] _e: i32 ) {} -// self, &self and &mut self +// self struct SelfStruct {} impl SelfStruct { fn foo( - #[allow(C)] self, + #[allow(unused_mut)] self, #[cfg(something)] a: i32, #[cfg_attr(something, cfg(nothing))] - #[deny(C)] b: i32, + #[deny(unused_mut)] b: i32, ) {} } struct RefStruct {} impl RefStruct { fn foo( - #[allow(C)] &self, + #[allow(unused_mut)] &self, #[cfg(something)] a: i32, #[cfg_attr(something, cfg(nothing))] - #[deny(C)] b: i32, + #[deny(unused_mut)] b: i32, ) {} } trait RefTrait { fn foo( - #[forbid(C)] &self, - #[warn(C)] a: i32 + #[forbid(unused_mut)] &self, + #[warn(unused_mut)] 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 + #[forbid(unused_mut)] &self, + #[warn(unused_mut)] a: i32 ) {} } @@ -192,22 +69,22 @@ impl NamedLifetimeMutTrait for NamedLifetimeMutStruct { struct BoxSelfStruct {} impl BoxSelfStruct { fn foo( - #[allow(C)] self: Box<Self>, + #[allow(unused_mut)] self: Box<Self>, #[cfg(something)] a: i32, #[cfg_attr(something, cfg(nothing))] - #[deny(C)] b: i32, + #[deny(unused_mut)] b: i32, ) {} } trait BoxSelfTrait { fn foo( - #[forbid(C)] self: Box<Self>, - #[warn(C)] a: i32 + #[forbid(unused_mut)] self: Box<Self>, + #[warn(unused_mut)] a: i32 ) {} } impl BoxSelfTrait for BoxSelfStruct { fn foo( - #[forbid(C)] self: Box<Self>, - #[warn(C)] a: i32 + #[forbid(unused_mut)] self: Box<Self>, + #[warn(unused_mut)] a: i32 ) {} } @@ -216,10 +93,10 @@ fn main() { let _: fn(_, _, _, _) = foo; let _: FnType = |_, _, _, _| {}; let c = | - #[allow(C)] a: u32, + #[allow(unused_mut)] a: u32, #[cfg(something)] b: i32, #[cfg_attr(something, cfg(nothing))] - #[deny(C)] c: i32, + #[deny(unused_mut)] c: i32, | {}; let _ = c(1, 2); } 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 index 977b5d9ce34..069332ffa25 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -1,6 +1,7 @@ // compile-flags: --cfg something +// edition:2018 -#![feature(param_attrs)] +#![feature(async_await, async_closure, param_attrs)] #![deny(unused_variables)] extern "C" { @@ -19,24 +20,35 @@ type FnType = fn( #[cfg_attr(something, cfg(nothing))] d: i32, ); +async fn foo_async( + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, +) {} fn foo( #[cfg(nothing)] a: i32, #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` [unused_variables] + //~^ ERROR unused variable: `b` #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` [unused_variables] + //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, ) {} struct RefStruct {} impl RefStruct { + async fn bar_async( + &self, + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, + ) {} fn bar( &self, #[cfg(nothing)] a: i32, #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` [unused_variables] + //~^ ERROR unused variable: `b` #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` [unused_variables] + //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, ) {} } @@ -45,9 +57,9 @@ trait RefTrait { &self, #[cfg(nothing)] a: i32, #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` [unused_variables] + //~^ ERROR unused variable: `b` #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` [unused_variables] + //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, ) {} } @@ -56,9 +68,9 @@ impl RefTrait for RefStruct { &self, #[cfg(nothing)] a: i32, #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` [unused_variables] + //~^ ERROR unused variable: `b` #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` [unused_variables] + //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, ) {} } @@ -67,13 +79,19 @@ fn main() { let _: unsafe extern "C" fn(_, ...) = ffi; let _: fn(_, _) = foo; let _: FnType = |_, _| {}; + let a = async move | + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, + | {}; let c = | #[cfg(nothing)] a: i32, #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` [unused_variables] + //~^ ERROR unused variable: `b` #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` [unused_variables] + //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, | {}; + let _ = a(1); 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 index c97190324e5..3232e2a0411 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr @@ -1,68 +1,86 @@ -error: unused variable: `b` +error: unused variable: `a` --> $DIR/param-attrs-cfg.rs:24:23 | -LL | #[cfg(something)] b: i32, - | ^ help: consider prefixing with an underscore: `_b` +LL | #[cfg(something)] a: i32, + | ^ help: consider prefixing with an underscore: `_a` | note: lint level defined here - --> $DIR/param-attrs-cfg.rs:4:9 + --> $DIR/param-attrs-cfg.rs:5:9 | LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:30:23 + | +LL | #[cfg(something)] b: i32, + | ^ help: consider prefixing with an underscore: `_b` + error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:26:40 + --> $DIR/param-attrs-cfg.rs:32:40 | LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, | ^ help: consider prefixing with an underscore: `_c` +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:83:27 + | +LL | #[cfg(something)] a: i32, + | ^ help: consider prefixing with an underscore: `_a` + error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:72:27 + --> $DIR/param-attrs-cfg.rs:89:27 | LL | #[cfg(something)] b: i32, | ^ help: consider prefixing with an underscore: `_b` error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:74:44 + --> $DIR/param-attrs-cfg.rs:91: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 + --> $DIR/param-attrs-cfg.rs:59:27 | LL | #[cfg(something)] b: i32, | ^ help: consider prefixing with an underscore: `_b` error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:49:44 + --> $DIR/param-attrs-cfg.rs:61:44 | LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, | ^ help: consider prefixing with an underscore: `_c` +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:41:27 + | +LL | #[cfg(something)] a: i32, + | ^ help: consider prefixing with an underscore: `_a` + error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:36:27 + --> $DIR/param-attrs-cfg.rs:48:27 | LL | #[cfg(something)] b: i32, | ^ help: consider prefixing with an underscore: `_b` error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:38:44 + --> $DIR/param-attrs-cfg.rs:50: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 + --> $DIR/param-attrs-cfg.rs:70:27 | LL | #[cfg(something)] b: i32, | ^ help: consider prefixing with an underscore: `_b` error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:60:44 + --> $DIR/param-attrs-cfg.rs:72:44 | LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, | ^ help: consider prefixing with an underscore: `_c` -error: aborting due to 10 previous errors +error: aborting due to 13 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 index c5a6514efb0..a7f4855915b 100644 --- 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 @@ -1,12 +1,14 @@ // gate-test-param_attrs +#![deny(unused_variables)] + 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 + #[allow(unused_variables)] a: u8 //~^ ERROR attributes on function parameters are unstable //~| NOTE https://github.com/rust-lang/rust/issues/60406 ) {} 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 index 704c41f0fa6..0bb9d05dca0 100644 --- 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 @@ -1,11 +1,11 @@ error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-feature-gate.rs:4:5 + --> $DIR/param-attrs-feature-gate.rs:6: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 + --> $DIR/param-attrs-feature-gate.rs:6:5 | LL | /// Foo | ^^^^^^^ @@ -14,10 +14,10 @@ LL | /// Foo = 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 + --> $DIR/param-attrs-feature-gate.rs:11:5 | -LL | #[allow(C)] a: u8 - | ^^^^^^^^^^^ +LL | #[allow(unused_variables)] 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 |
