Skip to content

Commit 8cc477f

Browse files
committed
Disambiguate Display::fmt calls for error types
1 parent 12ee459 commit 8cc477f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ simple_enum_error! {
9191
}
9292

9393
impl fmt::Display for ParseError {
94-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
95-
self.description().fmt(fmt)
94+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
95+
fmt::Display::fmt(self.description(), f)
9696
}
9797
}
9898

@@ -151,8 +151,8 @@ syntax_violation_enum! {
151151
}
152152

153153
impl fmt::Display for SyntaxViolation {
154-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
155-
self.description().fmt(fmt)
154+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
155+
fmt::Display::fmt(self.description(), f)
156156
}
157157
}
158158

tests/unit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ fn test_syntax_violation_callback() {
512512
let v = violation.take().unwrap();
513513
assert_eq!(v, ExpectedDoubleSlash);
514514
assert_eq!(v.description(), "expected //");
515+
assert_eq!(v.to_string(), "expected //");
515516
}
516517

517518
#[test]

0 commit comments

Comments
 (0)