Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #294 from dtolnay/context
Browse files Browse the repository at this point in the history
Eliminate repetitive line/column context from error message
  • Loading branch information
dtolnay committed Jul 29, 2022
2 parents 4167a95 + 4f88bf4 commit 492ac30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/libyaml/error.rs
Expand Up @@ -72,7 +72,10 @@ impl Display for Error {
}
if let Some(context) = &self.context {
write!(formatter, ", {}", context)?;
if self.context_mark.sys.line != 0 || self.context_mark.sys.column != 0 {
if (self.context_mark.sys.line != 0 || self.context_mark.sys.column != 0)
&& (self.context_mark.sys.line != self.problem_mark.sys.line
|| self.context_mark.sys.column != self.problem_mark.sys.column)
{
write!(formatter, " at {}", self.context_mark)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_error.rs
Expand Up @@ -132,7 +132,7 @@ fn test_second_document_syntax_error() {

let second_doc = de.next().unwrap();
let result = <usize as serde::Deserialize>::deserialize(second_doc);
let expected = "did not find expected node content at line 4 column 1, while parsing a block node at line 4 column 1";
let expected = "did not find expected node content at line 4 column 1, while parsing a block node";
assert_eq!(expected, result.unwrap_err().to_string());
}

Expand Down

0 comments on commit 492ac30

Please sign in to comment.