From 7fcf31b181433cc67b17af550d87fca1e3394f90 Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 7 Dec 2018 11:16:13 +0100 Subject: Add suggestion for underscore binding fix. This commit emits a suggestion for adding an underscore binding to arguments in trait methods that previously did not have a argument name specified. --- src/libsyntax/parse/parser.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index af63314b154..560078136eb 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)"); } -- cgit 1.4.1-3-g733a5