Suggest replacing patterns with underscores

This commit is contained in:
varkor 2018-08-04 11:48:33 +01:00
parent 90a6954327
commit b05f0bec1a
2 changed files with 6 additions and 3 deletions

View File

@ -344,8 +344,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
trait_item.id, span,
"patterns aren't allowed in methods without bodies");
} else {
struct_span_err!(self.session, span, E0642,
"patterns aren't allowed in methods without bodies").emit();
let mut err = struct_span_err!(self.session, span, E0642,
"patterns aren't allowed in methods without bodies");
err.span_suggestion(span,
"use an underscore to ignore the name", "_".to_owned());
err.emit();
}
});
}

View File

@ -2,7 +2,7 @@ error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/E0642.rs:12:12
|
LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
| ^^^^^^
| ^^^^^^ help: use an underscore to ignore the name: `_`
error: aborting due to previous error