diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index af63314b15447..560078136eb8c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1850,6 +1850,15 @@ impl<'a> Parser<'a> { Applicability::HasPlaceholders, ); } else if require_name && is_trait_item { + if let PatKind::Ident(_, ident, _) = pat.node { + err.span_suggestion_with_applicability( + pat.span, + "explicitly ignore parameter", + format!("_: {}", ident), + Applicability::MachineApplicable, + ); + } + err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); } diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params-denied-2018.stderr index e1aa65981f6fd..dd9e933542fa7 100644 --- a/src/test/ui/anon-params-denied-2018.stderr +++ b/src/test/ui/anon-params-denied-2018.stderr @@ -2,7 +2,9 @@ error: expected one of `:` or `@`, found `)` --> $DIR/anon-params-denied-2018.rs:6:15 | LL | fn foo(i32); //~ expected one of `:` or `@`, found `)` - | ^ expected one of `:` or `@` here + | ---^ expected one of `:` or `@` here + | | + | help: explicitly ignore parameter: `_: i32` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) @@ -10,7 +12,9 @@ error: expected one of `:` or `@`, found `,` --> $DIR/anon-params-denied-2018.rs:8:36 | LL | fn bar_with_default_impl(String, String) {} - | ^ expected one of `:` or `@` here + | ------^ expected one of `:` or `@` here + | | + | help: explicitly ignore parameter: `_: String` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)