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

View file

@ -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)