Skip to content

Commit

Permalink
Disambiguate Display::fmt calls for error types
Browse files Browse the repository at this point in the history
  • Loading branch information
dekellum committed Jul 22, 2019
1 parent 12ee459 commit 8cc477f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ simple_enum_error! {
}

impl fmt::Display for ParseError {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
self.description().fmt(fmt)
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
fmt::Display::fmt(self.description(), f)
}
}

Expand Down Expand Up @@ -151,8 +151,8 @@ syntax_violation_enum! {
}

impl fmt::Display for SyntaxViolation {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
self.description().fmt(fmt)
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
fmt::Display::fmt(self.description(), f)
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ fn test_syntax_violation_callback() {
let v = violation.take().unwrap();
assert_eq!(v, ExpectedDoubleSlash);
assert_eq!(v.description(), "expected //");
assert_eq!(v.to_string(), "expected //");
}

#[test]
Expand Down

0 comments on commit 8cc477f

Please sign in to comment.