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.
This commit is contained in:
David Wood
2018-12-07 11:16:13 +01:00
parent e4dc15a969
commit 7fcf31b181
2 changed files with 15 additions and 2 deletions

View File

@@ -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)");
}