1
Fork 0

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
No known key found for this signature in database
GPG key ID: 01760B4F9F53F154
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)");
}