diff options
| author | varkor <github@varkor.com> | 2018-08-04 11:48:33 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-08-11 21:08:24 +0100 |
| commit | b05f0bec1a6f576cd275e52a8a0a0165fb25f77a (patch) | |
| tree | c32636c0d93c24ed94a2aee17a94131394c02619 | |
| parent | 90a6954327bb4f018eab155f43299d4bf67abe41 (diff) | |
| download | rust-b05f0bec1a6f576cd275e52a8a0a0165fb25f77a.tar.gz rust-b05f0bec1a6f576cd275e52a8a0a0165fb25f77a.zip | |
Suggest replacing patterns with underscores
| -rw-r--r-- | src/librustc_passes/ast_validation.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/E0642.stderr | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 0ea90e74531..c75ae07fe66 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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(); } }); } diff --git a/src/test/ui/E0642.stderr b/src/test/ui/E0642.stderr index edc430d578b..5291c016c7f 100644 --- a/src/test/ui/E0642.stderr +++ b/src/test/ui/E0642.stderr @@ -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 |
