Skip to content

Commit

Permalink
[xmlparser] Use TextPositions own fmt
Browse files Browse the repository at this point in the history
TextPosition starts counting line numbers at 0. There is a ready made
implementation of `fmt::Display` that accounts for this when showing a
TextPosition to a human.
Use this implementation instead of manually showing the zero-indexed
line number.
  • Loading branch information
timbodeit committed Nov 29, 2019
1 parent 7589cc6 commit 9ca45e8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/xmlparser.rs
Expand Up @@ -38,10 +38,9 @@ impl ErrorEmitter {
pub fn emit(&self, message: &str, position: TextPosition) -> String {
let enriched = match self.path {
Some(ref path) => format!(
"{} at line {}:{}: {}",
"{} at line {}: {}",
path.display(),
position.row,
position.column,
position,
message
),
None => format!("{} {}", position, message),
Expand Down

0 comments on commit 9ca45e8

Please sign in to comment.