From d2dfc9cea3c221bbbfc4195a50471882f85ca42f Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 22 Aug 2018 13:43:04 -0500 Subject: [PATCH 1/6] Remove anon trait params from 2018 and beyond --- src/libsyntax/parse/parser.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 725360b842d43..a8f65cee51396 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1376,7 +1376,13 @@ impl<'a> Parser<'a> { // This is somewhat dubious; We don't want to allow // argument names to be left off if there is a // definition... - p.parse_arg_general(false) + + // We don't allow argument names to be left off in edition 2018. + if self.span.edition() >= Edition::Edition2018 { + p.parse_arg_general(true) + } else { + p.parse_arg_general(false) + } })?; generics.where_clause = self.parse_where_clause()?; From 3e073ab1110db70b8fd0f7c16a8ebe7020eb6bde Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 22 Aug 2018 13:58:46 -0500 Subject: [PATCH 2/6] fix compile error --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a8f65cee51396..1695d3a8f96b0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1378,7 +1378,7 @@ impl<'a> Parser<'a> { // definition... // We don't allow argument names to be left off in edition 2018. - if self.span.edition() >= Edition::Edition2018 { + if p.span.edition() >= Edition::Edition2018 { p.parse_arg_general(true) } else { p.parse_arg_general(false) From 3c3c642a05c7624cb77acefed37491a8ddb1f4f1 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 22 Aug 2018 14:08:29 -0500 Subject: [PATCH 3/6] Start working on a test --- src/test/ui/anon-params-denied-2018.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/ui/anon-params-denied-2018.rs diff --git a/src/test/ui/anon-params-denied-2018.rs b/src/test/ui/anon-params-denied-2018.rs new file mode 100644 index 0000000000000..1489cccc5fbb9 --- /dev/null +++ b/src/test/ui/anon-params-denied-2018.rs @@ -0,0 +1,13 @@ +// Test that anonymous parameters are disallowed in 2018 edition. + +// edition:2018 + +trait T { + fn foo(i32); //~ ERROR expected identifier + + fn bar_with_default_impl(String, String) {} + //~^ ERROR expected identifier + //~| ERROR expected identifier +} + +fn main() {} From 88037a558711e5182535c577de91429445586634 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 22 Aug 2018 15:07:27 -0500 Subject: [PATCH 4/6] Add/update tests for 2015, 2018, rustfix --- src/test/ui/anon-params-denied-2018.rs | 17 +++++++++-- src/test/ui/anon-params-denied-2018.stderr | 14 +++++++++ src/test/ui/anon-params-deprecated.fixed | 29 +++++++++++++++++++ src/test/ui/anon-params-deprecated.rs | 12 +++++--- src/test/ui/anon-params-deprecated.stderr | 22 +++++++------- .../ui/lint/lint-anon-param-edition.fixed | 23 --------------- src/test/ui/lint/lint-anon-param-edition.rs | 23 --------------- .../ui/lint/lint-anon-param-edition.stderr | 10 ------- 8 files changed, 75 insertions(+), 75 deletions(-) create mode 100644 src/test/ui/anon-params-denied-2018.stderr create mode 100644 src/test/ui/anon-params-deprecated.fixed delete mode 100644 src/test/ui/lint/lint-anon-param-edition.fixed delete mode 100644 src/test/ui/lint/lint-anon-param-edition.rs delete mode 100644 src/test/ui/lint/lint-anon-param-edition.stderr diff --git a/src/test/ui/anon-params-denied-2018.rs b/src/test/ui/anon-params-denied-2018.rs index 1489cccc5fbb9..064355a6334f2 100644 --- a/src/test/ui/anon-params-denied-2018.rs +++ b/src/test/ui/anon-params-denied-2018.rs @@ -1,13 +1,24 @@ // Test that anonymous parameters are disallowed in 2018 edition. +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that anonymous parameters are a hard error in edition 2018. + // edition:2018 trait T { - fn foo(i32); //~ ERROR expected identifier + fn foo(i32); //~ expected one of `:` or `@`, found `)` fn bar_with_default_impl(String, String) {} - //~^ ERROR expected identifier - //~| ERROR expected identifier + //~^ ERROR expected one of `:` or `@`, found `,` } fn main() {} diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params-denied-2018.stderr new file mode 100644 index 0000000000000..0603ddaa6c04b --- /dev/null +++ b/src/test/ui/anon-params-denied-2018.stderr @@ -0,0 +1,14 @@ +error: expected one of `:` or `@`, found `)` + --> $DIR/anon-params-denied-2018.rs:18:15 + | +LL | fn foo(i32); //~ expected one of `:` or `@`, found `)` + | ^ expected one of `:` or `@` here + +error: expected one of `:` or `@`, found `,` + --> $DIR/anon-params-denied-2018.rs:20:36 + | +LL | fn bar_with_default_impl(String, String) {} + | ^ expected one of `:` or `@` here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/anon-params-deprecated.fixed b/src/test/ui/anon-params-deprecated.fixed new file mode 100644 index 0000000000000..11d12f8df559d --- /dev/null +++ b/src/test/ui/anon-params-deprecated.fixed @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![warn(anonymous_parameters)] +// Test for the anonymous_parameters deprecation lint (RFC 1685) + +// compile-pass +// edition:2015 +// run-rustfix + +trait T { + fn foo(_: i32); //~ WARNING anonymous parameters are deprecated + //~| WARNING hard error + + fn bar_with_default_impl(_: String, _: String) {} + //~^ WARNING anonymous parameters are deprecated + //~| WARNING hard error + //~| WARNING anonymous parameters are deprecated + //~| WARNING hard error +} + +fn main() {} diff --git a/src/test/ui/anon-params-deprecated.rs b/src/test/ui/anon-params-deprecated.rs index 4d37ba920f3d6..2cc0cdeb34de9 100644 --- a/src/test/ui/anon-params-deprecated.rs +++ b/src/test/ui/anon-params-deprecated.rs @@ -8,17 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![forbid(anonymous_parameters)] +#![warn(anonymous_parameters)] // Test for the anonymous_parameters deprecation lint (RFC 1685) +// compile-pass +// edition:2015 +// run-rustfix + trait T { - fn foo(i32); //~ ERROR anonymous parameters are deprecated + fn foo(i32); //~ WARNING anonymous parameters are deprecated //~| WARNING hard error fn bar_with_default_impl(String, String) {} - //~^ ERROR anonymous parameters are deprecated + //~^ WARNING anonymous parameters are deprecated //~| WARNING hard error - //~| ERROR anonymous parameters are deprecated + //~| WARNING anonymous parameters are deprecated //~| WARNING hard error } diff --git a/src/test/ui/anon-params-deprecated.stderr b/src/test/ui/anon-params-deprecated.stderr index fa13b8d97e5d9..3d4e8febbfadb 100644 --- a/src/test/ui/anon-params-deprecated.stderr +++ b/src/test/ui/anon-params-deprecated.stderr @@ -1,19 +1,19 @@ -error: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:15:12 +warning: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:19:12 | -LL | fn foo(i32); //~ ERROR anonymous parameters are deprecated +LL | fn foo(i32); //~ WARNING anonymous parameters are deprecated | ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32` | note: lint level defined here - --> $DIR/anon-params-deprecated.rs:11:11 + --> $DIR/anon-params-deprecated.rs:11:9 | -LL | #![forbid(anonymous_parameters)] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #![warn(anonymous_parameters)] + | ^^^^^^^^^^^^^^^^^^^^ = 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 #41686 -error: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:18:30 +warning: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:22:30 | LL | fn bar_with_default_impl(String, String) {} | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` @@ -21,8 +21,8 @@ LL | fn bar_with_default_impl(String, String) {} = 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 #41686 -error: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:18:38 +warning: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:22:38 | LL | fn bar_with_default_impl(String, String) {} | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` @@ -30,5 +30,3 @@ LL | fn bar_with_default_impl(String, String) {} = 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 #41686 -error: aborting due to 3 previous errors - diff --git a/src/test/ui/lint/lint-anon-param-edition.fixed b/src/test/ui/lint/lint-anon-param-edition.fixed deleted file mode 100644 index c4379b496f8d4..0000000000000 --- a/src/test/ui/lint/lint-anon-param-edition.fixed +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// tests that the anonymous_parameters lint is warn-by-default on the 2018 edition - -// compile-pass -// edition:2018 -// run-rustfix - -trait Foo { - fn foo(_: u8); - //^ WARN anonymous parameters are deprecated - //| WARN this was previously accepted -} - -fn main() {} diff --git a/src/test/ui/lint/lint-anon-param-edition.rs b/src/test/ui/lint/lint-anon-param-edition.rs deleted file mode 100644 index 13eb5dfd816ab..0000000000000 --- a/src/test/ui/lint/lint-anon-param-edition.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// tests that the anonymous_parameters lint is warn-by-default on the 2018 edition - -// compile-pass -// edition:2018 -// run-rustfix - -trait Foo { - fn foo(u8); - //^ WARN anonymous parameters are deprecated - //| WARN this was previously accepted -} - -fn main() {} diff --git a/src/test/ui/lint/lint-anon-param-edition.stderr b/src/test/ui/lint/lint-anon-param-edition.stderr deleted file mode 100644 index de347770aec77..0000000000000 --- a/src/test/ui/lint/lint-anon-param-edition.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/lint-anon-param-edition.rs:18:12 - | -LL | fn foo(u8); - | ^^ help: Try naming the parameter or explicitly ignoring it: `_: u8` - | - = note: #[warn(anonymous_parameters)] on by default - = 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 #41686 - From 0cec1b92c357cef2be97324d0338d7dc8d6062d7 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 22 Aug 2018 16:43:32 -0500 Subject: [PATCH 5/6] oops --- src/test/ui/anon-params-denied-2018.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/ui/anon-params-denied-2018.rs b/src/test/ui/anon-params-denied-2018.rs index 064355a6334f2..5fc6d3f0c5238 100644 --- a/src/test/ui/anon-params-denied-2018.rs +++ b/src/test/ui/anon-params-denied-2018.rs @@ -1,5 +1,3 @@ -// Test that anonymous parameters are disallowed in 2018 edition. - // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. From b32b6e803b8e7ad1ee2258ef5784af7e4010be4b Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 24 Aug 2018 15:47:25 -0500 Subject: [PATCH 6/6] fix tests --- src/test/ui/anon-params-denied-2018.rs | 10 ---------- src/test/ui/anon-params-denied-2018.stderr | 4 ++-- src/test/ui/anon-params-deprecated.fixed | 10 ---------- src/test/ui/anon-params-deprecated.rs | 10 ---------- src/test/ui/anon-params-deprecated.stderr | 8 ++++---- 5 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/test/ui/anon-params-denied-2018.rs b/src/test/ui/anon-params-denied-2018.rs index 5fc6d3f0c5238..5e77aa8fbb923 100644 --- a/src/test/ui/anon-params-denied-2018.rs +++ b/src/test/ui/anon-params-denied-2018.rs @@ -1,13 +1,3 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // Tests that anonymous parameters are a hard error in edition 2018. // edition:2018 diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params-denied-2018.stderr index 0603ddaa6c04b..24a1e6ecd932c 100644 --- a/src/test/ui/anon-params-denied-2018.stderr +++ b/src/test/ui/anon-params-denied-2018.stderr @@ -1,11 +1,11 @@ error: expected one of `:` or `@`, found `)` - --> $DIR/anon-params-denied-2018.rs:18:15 + --> $DIR/anon-params-denied-2018.rs:6:15 | LL | fn foo(i32); //~ expected one of `:` or `@`, found `)` | ^ expected one of `:` or `@` here error: expected one of `:` or `@`, found `,` - --> $DIR/anon-params-denied-2018.rs:20:36 + --> $DIR/anon-params-denied-2018.rs:8:36 | LL | fn bar_with_default_impl(String, String) {} | ^ expected one of `:` or `@` here diff --git a/src/test/ui/anon-params-deprecated.fixed b/src/test/ui/anon-params-deprecated.fixed index 11d12f8df559d..7eee47dcb5fc7 100644 --- a/src/test/ui/anon-params-deprecated.fixed +++ b/src/test/ui/anon-params-deprecated.fixed @@ -1,13 +1,3 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(anonymous_parameters)] // Test for the anonymous_parameters deprecation lint (RFC 1685) diff --git a/src/test/ui/anon-params-deprecated.rs b/src/test/ui/anon-params-deprecated.rs index 2cc0cdeb34de9..74de0c0b83407 100644 --- a/src/test/ui/anon-params-deprecated.rs +++ b/src/test/ui/anon-params-deprecated.rs @@ -1,13 +1,3 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #![warn(anonymous_parameters)] // Test for the anonymous_parameters deprecation lint (RFC 1685) diff --git a/src/test/ui/anon-params-deprecated.stderr b/src/test/ui/anon-params-deprecated.stderr index 3d4e8febbfadb..e1c27ceefa9e0 100644 --- a/src/test/ui/anon-params-deprecated.stderr +++ b/src/test/ui/anon-params-deprecated.stderr @@ -1,11 +1,11 @@ warning: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:19:12 + --> $DIR/anon-params-deprecated.rs:9:12 | LL | fn foo(i32); //~ WARNING anonymous parameters are deprecated | ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32` | note: lint level defined here - --> $DIR/anon-params-deprecated.rs:11:9 + --> $DIR/anon-params-deprecated.rs:1:9 | LL | #![warn(anonymous_parameters)] | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![warn(anonymous_parameters)] = note: for more information, see issue #41686 warning: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:22:30 + --> $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` @@ -22,7 +22,7 @@ LL | fn bar_with_default_impl(String, String) {} = note: for more information, see issue #41686 warning: anonymous parameters are deprecated and will be removed in the next edition. - --> $DIR/anon-params-deprecated.rs:22:38 + --> $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`