Skip to content

Commit 49e9c5f

Browse files
committed
Add E0642 to parser error
1 parent e4c3b49 commit 49e9c5f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/libsyntax/parse/parser.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use ast::{RangeEnd, RangeSyntax};
4444
use {ast, attr};
4545
use codemap::{self, CodeMap, Spanned, respan};
4646
use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition};
47-
use errors::{self, Applicability, DiagnosticBuilder};
47+
use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
4848
use parse::{self, SeqSep, classify, token};
4949
use parse::lexer::TokenAndSpan;
5050
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
@@ -1775,8 +1775,11 @@ impl<'a> Parser<'a> {
17751775

17761776
match pat_arg {
17771777
Ok((pat, ty)) => {
1778-
let mut err = self.diagnostic()
1779-
.struct_span_err(pat.span, "patterns aren't allowed in trait methods");
1778+
let mut err = self.diagnostic().struct_span_err_with_code(
1779+
pat.span,
1780+
"patterns aren't allowed in trait methods",
1781+
DiagnosticId::Error("E0642".into()),
1782+
);
17801783
err.span_suggestion_short_with_applicability(
17811784
pat.span,
17821785
"give this argument a name or use an underscore to ignore it",

src/test/ui/E0642.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: patterns aren't allowed in trait methods
1+
error[E0642]: patterns aren't allowed in trait methods
22
--> $DIR/E0642.rs:12:12
33
|
44
LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in trait methods
@@ -8,7 +8,7 @@ help: give this argument a name or use an underscore to ignore it
88
LL | fn foo(_: (i32, i32)); //~ ERROR patterns aren't allowed in trait methods
99
| ^
1010

11-
error: patterns aren't allowed in trait methods
11+
error[E0642]: patterns aren't allowed in trait methods
1212
--> $DIR/E0642.rs:16:12
1313
|
1414
LL | fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in trait methods
@@ -20,3 +20,4 @@ LL | fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in trait met
2020

2121
error: aborting due to 2 previous errors
2222

23+
For more information about this error, try `rustc --explain E0642`.

0 commit comments

Comments
 (0)