From 49e9c5fe90db9a70697da8a3bf4237492376c541 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 10 Aug 2018 01:49:45 +0100 Subject: [PATCH] Add E0642 to parser error --- src/libsyntax/parse/parser.rs | 9 ++++++--- src/test/ui/E0642.stderr | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9a49d705c464..14026c5bede6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -44,7 +44,7 @@ use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; use codemap::{self, CodeMap, Spanned, respan}; use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition}; -use errors::{self, Applicability, DiagnosticBuilder}; +use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId}; use parse::{self, SeqSep, classify, token}; use parse::lexer::TokenAndSpan; use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; @@ -1775,8 +1775,11 @@ impl<'a> Parser<'a> { match pat_arg { Ok((pat, ty)) => { - let mut err = self.diagnostic() - .struct_span_err(pat.span, "patterns aren't allowed in trait methods"); + let mut err = self.diagnostic().struct_span_err_with_code( + pat.span, + "patterns aren't allowed in trait methods", + DiagnosticId::Error("E0642".into()), + ); err.span_suggestion_short_with_applicability( pat.span, "give this argument a name or use an underscore to ignore it", diff --git a/src/test/ui/E0642.stderr b/src/test/ui/E0642.stderr index b8e0496945a1..1723e97b45e4 100644 --- a/src/test/ui/E0642.stderr +++ b/src/test/ui/E0642.stderr @@ -1,4 +1,4 @@ -error: patterns aren't allowed in trait methods +error[E0642]: patterns aren't allowed in trait methods --> $DIR/E0642.rs:12:12 | 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 LL | fn foo(_: (i32, i32)); //~ ERROR patterns aren't allowed in trait methods | ^ -error: patterns aren't allowed in trait methods +error[E0642]: patterns aren't allowed in trait methods --> $DIR/E0642.rs:16:12 | 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 error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0642`.