Fix positions.

This commit is contained in:
Stephen Chung
2022-02-10 17:55:32 +08:00
parent 3050e38c5e
commit d23d1159ab
10 changed files with 95 additions and 53 deletions

View File

@@ -257,16 +257,19 @@ impl fmt::Display for Position {
impl fmt::Debug for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(not(feature = "no_position"))]
if self.is_beginning_of_line() {
write!(f, "{}", self.line)?;
if self.is_none() {
f.write_str("none")
} else {
write!(f, "{}:{}", self.line, self.pos)?;
}
#[cfg(feature = "no_position")]
f.write_str("none")?;
#[cfg(not(feature = "no_position"))]
if self.is_beginning_of_line() {
write!(f, "{}", self.line)
} else {
write!(f, "{}:{}", self.line, self.pos)
}
Ok(())
#[cfg(feature = "no_position")]
unreachable!();
}
}
}