From 9367b9a2920073a3f79fdff80dcc97d727f6ce17 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Thu, 30 Jan 2020 00:18:21 +0200 Subject: [PATCH] ra_syntax: add backticks around tokens specimen --- crates/ra_syntax/src/syntax_error.rs | 35 ++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs index 45e11f404ea..7f9d366184b 100644 --- a/crates/ra_syntax/src/syntax_error.rs +++ b/crates/ra_syntax/src/syntax_error.rs @@ -71,6 +71,10 @@ impl SyntaxError { self } + + pub fn debug_dump(&self, acc: &mut impl fmt::Write) { + writeln!(acc, "error {:?}: {}", self.location(), self.kind()).unwrap(); + } } impl fmt::Display for SyntaxError { @@ -122,37 +126,44 @@ impl fmt::Display for SyntaxErrorKind { impl fmt::Display for TokenizeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[rustfmt::skip] let msg = match self { - TokenizeError::EmptyInt => "Missing digits after integer base prefix", - TokenizeError::EmptyExponent => "Missing digits after the exponent symbol", + TokenizeError::EmptyInt => { + "Missing digits after the integer base prefix" + } + TokenizeError::EmptyExponent => { + "Missing digits after the exponent symbol" + } TokenizeError::UnterminatedBlockComment => { - "Missing trailing */ symbols to terminate the block comment" + "Missing trailing `*/` symbols to terminate the block comment" } TokenizeError::UnterminatedChar => { - "Missing trailing ' symbol to terminate the character literal" + "Missing trailing `'` symbol to terminate the character literal" } TokenizeError::UnterminatedByte => { - "Missing trailing ' symbol to terminate the byte literal" + "Missing trailing `'` symbol to terminate the byte literal" } TokenizeError::UnterminatedString => { - "Missing trailing \" symbol to terminate the string literal" + "Missing trailing `\"` symbol to terminate the string literal" } TokenizeError::UnterminatedByteString => { - "Missing trailing \" symbol to terminate the byte string literal" + "Missing trailing `\"` symbol to terminate the byte string literal" } TokenizeError::UnterminatedRawString => { - "Missing trailing \" with # symbols to terminate the raw string literal" + "Missing trailing `\"` with `#` symbols to terminate the raw string literal" } TokenizeError::UnterminatedRawByteString => { - "Missing trailing \" with # symbols to terminate the raw byte string literal" + "Missing trailing `\"` with `#` symbols to terminate the raw byte string literal" } TokenizeError::UnstartedRawString => { - "Missing \" symbol after # symbols to begin the raw string literal" + "Missing `\"` symbol after `#` symbols to begin the raw string literal" } TokenizeError::UnstartedRawByteString => { - "Missing \" symbol after # symbols to begin the raw byte string literal" + "Missing `\"` symbol after `#` symbols to begin the raw byte string literal" + } + TokenizeError::LifetimeStartsWithNumber => { + "Lifetime name cannot start with a number" } - TokenizeError::LifetimeStartsWithNumber => "Lifetime name cannot start with a number", }; write!(f, "{}", msg) }