Condense the Debug representation for Error
This representation appears in panic messages when someone unwraps a
syn::Error, so it benefits from cutting down noise.
Before:
Error { start_span: Span, end_span: Span, message: "expected identifier" }
After:
Error("expected identifier")
diff --git a/src/error.rs b/src/error.rs
index e07051d..097a6b8 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,5 +1,5 @@
use std;
-use std::fmt::{self, Display};
+use std::fmt::{self, Debug, Display};
use std::iter::FromIterator;
use proc_macro2::{
@@ -24,7 +24,6 @@
/// [module documentation]: index.html
///
/// *This type is available if Syn is built with the `"parsing"` feature.*
-#[derive(Debug)]
pub struct Error {
// Span is implemented as an index into a thread-local interner to keep the
// size small. It is not safe to access from a different thread. We want
@@ -181,6 +180,12 @@
}
}
+impl Debug for Error {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ formatter.debug_tuple("Error").field(&self.message).finish()
+ }
+}
+
impl Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str(&self.message)