diff options
Diffstat (limited to 'tests/ui/anon-params')
-rw-r--r-- | tests/ui/anon-params/anon-params-denied-2018.rs | 32 | ||||
-rw-r--r-- | tests/ui/anon-params/anon-params-denied-2018.stderr | 142 | ||||
-rw-r--r-- | tests/ui/anon-params/anon-params-deprecated.fixed | 19 | ||||
-rw-r--r-- | tests/ui/anon-params/anon-params-deprecated.rs | 19 | ||||
-rw-r--r-- | tests/ui/anon-params/anon-params-deprecated.stderr | 34 | ||||
-rw-r--r-- | tests/ui/anon-params/anon-params-edition-hygiene.rs | 13 | ||||
-rw-r--r-- | tests/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs | 12 |
7 files changed, 271 insertions, 0 deletions
diff --git a/tests/ui/anon-params/anon-params-denied-2018.rs b/tests/ui/anon-params/anon-params-denied-2018.rs new file mode 100644 index 000000000..95533cf3d --- /dev/null +++ b/tests/ui/anon-params/anon-params-denied-2018.rs @@ -0,0 +1,32 @@ +// Tests that anonymous parameters are a hard error in edition 2018. + +// edition:2018 + +trait T { + fn foo(i32); //~ expected one of `:`, `@`, or `|`, found `)` + + // Also checks with `&` + fn foo_with_ref(&mut i32); + //~^ ERROR expected one of `:`, `@`, or `|`, found `)` + + fn foo_with_qualified_path(<Bar as T>::Baz); + //~^ ERROR expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + + fn foo_with_qualified_path_and_ref(&<Bar as T>::Baz); + //~^ ERROR expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + + fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz); + //~^ ERROR expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `,` + //~| ERROR expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + + fn bar_with_default_impl(String, String) {} + //~^ ERROR expected one of `:` + //~| ERROR expected one of `:` + + // do not complain about missing `b` + fn baz(a:usize, b, c: usize) -> usize { //~ ERROR expected one of `:` + a + b + c + } +} + +fn main() {} diff --git a/tests/ui/anon-params/anon-params-denied-2018.stderr b/tests/ui/anon-params/anon-params-denied-2018.stderr new file mode 100644 index 000000000..bb60c898e --- /dev/null +++ b/tests/ui/anon-params/anon-params-denied-2018.stderr @@ -0,0 +1,142 @@ +error: expected one of `:`, `@`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:6:15 + | +LL | fn foo(i32); + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn foo(self: i32); + | +++++ +help: if this is a parameter name, give it a type + | +LL | fn foo(i32: TypeName); + | ++++++++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn foo(_: i32); + | ++ + +error: expected one of `:`, `@`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:9:29 + | +LL | fn foo_with_ref(&mut i32); + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn foo_with_ref(self: &mut i32); + | +++++ +help: if this is a parameter name, give it a type + | +LL | fn foo_with_ref(i32: &mut TypeName); + | ~~~~~~~~~~~~~~~~~~ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn foo_with_ref(_: &mut i32); + | ++ + +error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:12:47 + | +LL | fn foo_with_qualified_path(<Bar as T>::Baz); + | ^ expected one of 8 possible tokens + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: explicitly ignore the parameter name + | +LL | fn foo_with_qualified_path(_: <Bar as T>::Baz); + | ~~~~~~~~~~~~~~~~~~ + +error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:15:56 + | +LL | fn foo_with_qualified_path_and_ref(&<Bar as T>::Baz); + | ^ expected one of 8 possible tokens + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: explicitly ignore the parameter name + | +LL | fn foo_with_qualified_path_and_ref(_: &<Bar as T>::Baz); + | ~~~~~~~~~~~~~~~~~~~ + +error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `,` + --> $DIR/anon-params-denied-2018.rs:18:57 + | +LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz); + | ^ expected one of 8 possible tokens + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: explicitly ignore the parameter name + | +LL | fn foo_with_multiple_qualified_paths(_: <Bar as T>::Baz, <Bar as T>::Baz); + | ~~~~~~~~~~~~~~~~~~ + +error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:18:74 + | +LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz); + | ^ expected one of 8 possible tokens + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: explicitly ignore the parameter name + | +LL | fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, _: <Bar as T>::Baz); + | ~~~~~~~~~~~~~~~~~~ + +error: expected one of `:`, `@`, or `|`, found `,` + --> $DIR/anon-params-denied-2018.rs:22:36 + | +LL | fn bar_with_default_impl(String, String) {} + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn bar_with_default_impl(self: String, String) {} + | +++++ +help: if this is a parameter name, give it a type + | +LL | fn bar_with_default_impl(String: TypeName, String) {} + | ++++++++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn bar_with_default_impl(_: String, String) {} + | ++ + +error: expected one of `:`, `@`, or `|`, found `)` + --> $DIR/anon-params-denied-2018.rs:22:44 + | +LL | fn bar_with_default_impl(String, String) {} + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a parameter name, give it a type + | +LL | fn bar_with_default_impl(String, String: TypeName) {} + | ++++++++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn bar_with_default_impl(String, _: String) {} + | ++ + +error: expected one of `:`, `@`, or `|`, found `,` + --> $DIR/anon-params-denied-2018.rs:27:22 + | +LL | fn baz(a:usize, b, c: usize) -> usize { + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a parameter name, give it a type + | +LL | fn baz(a:usize, b: TypeName, c: usize) -> usize { + | ++++++++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn baz(a:usize, _: b, c: usize) -> usize { + | ++ + +error: aborting due to 9 previous errors + diff --git a/tests/ui/anon-params/anon-params-deprecated.fixed b/tests/ui/anon-params/anon-params-deprecated.fixed new file mode 100644 index 000000000..c09e20770 --- /dev/null +++ b/tests/ui/anon-params/anon-params-deprecated.fixed @@ -0,0 +1,19 @@ +#![warn(anonymous_parameters)] +// Test for the anonymous_parameters deprecation lint (RFC 1685) + +// check-pass +// edition:2015 +// run-rustfix + +trait T { + fn foo(_: i32); //~ WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition + + fn bar_with_default_impl(_: String, _: String) {} + //~^ WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition + //~| WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition +} + +fn main() {} diff --git a/tests/ui/anon-params/anon-params-deprecated.rs b/tests/ui/anon-params/anon-params-deprecated.rs new file mode 100644 index 000000000..6f7385da0 --- /dev/null +++ b/tests/ui/anon-params/anon-params-deprecated.rs @@ -0,0 +1,19 @@ +#![warn(anonymous_parameters)] +// Test for the anonymous_parameters deprecation lint (RFC 1685) + +// check-pass +// edition:2015 +// run-rustfix + +trait T { + fn foo(i32); //~ WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition + + fn bar_with_default_impl(String, String) {} + //~^ WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition + //~| WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition +} + +fn main() {} diff --git a/tests/ui/anon-params/anon-params-deprecated.stderr b/tests/ui/anon-params/anon-params-deprecated.stderr new file mode 100644 index 000000000..691e2c795 --- /dev/null +++ b/tests/ui/anon-params/anon-params-deprecated.stderr @@ -0,0 +1,34 @@ +warning: anonymous parameters are deprecated and will be removed in the next edition + --> $DIR/anon-params-deprecated.rs:9:12 + | +LL | fn foo(i32); + | ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> +note: the lint level is defined here + --> $DIR/anon-params-deprecated.rs:1:9 + | +LL | #![warn(anonymous_parameters)] + | ^^^^^^^^^^^^^^^^^^^^ + +warning: anonymous parameters are deprecated and will be removed in the next edition + --> $DIR/anon-params-deprecated.rs:12:30 + | +LL | fn bar_with_default_impl(String, String) {} + | ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> + +warning: anonymous parameters are deprecated and will be removed in the next edition + --> $DIR/anon-params-deprecated.rs:12:38 + | +LL | fn bar_with_default_impl(String, String) {} + | ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> + +warning: 3 warnings emitted + diff --git a/tests/ui/anon-params/anon-params-edition-hygiene.rs b/tests/ui/anon-params/anon-params-edition-hygiene.rs new file mode 100644 index 000000000..6936205f8 --- /dev/null +++ b/tests/ui/anon-params/anon-params-edition-hygiene.rs @@ -0,0 +1,13 @@ +// check-pass +// edition:2018 +// aux-build:anon-params-edition-hygiene.rs + +// This warning is still surfaced +#![allow(anonymous_parameters)] + +#[macro_use] +extern crate anon_params_edition_hygiene; + +generate_trait_2015!(u8); + +fn main() {} diff --git a/tests/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs b/tests/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs new file mode 100644 index 000000000..aa4221bec --- /dev/null +++ b/tests/ui/anon-params/auxiliary/anon-params-edition-hygiene.rs @@ -0,0 +1,12 @@ +// edition:2015 + +#[macro_export] +macro_rules! generate_trait_2015 { + ($Type: ident) => { + trait Trait { + fn method($Type) {} + } + }; +} + +fn main() {} |