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

Commit

Permalink
Omit position 0 from error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 30, 2022
1 parent 3562a13 commit 1c031a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ impl ErrorImpl {
_ => {
self.message_no_mark(f)?;
if let Some(mark) = self.mark() {
write!(f, " at {}", mark)?;
if mark.line() != 0 || mark.column() != 0 {
write!(f, " at {}", mark)?;
}
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions tests/test_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn test_missing_enum_tag() {
"V": 16
"other": 32
"#};
let expected = "invalid type: map, expected a YAML tag starting with '!' at position 0";
let expected = "invalid type: map, expected a YAML tag starting with '!'";
test_error::<E>(yaml, expected);
}

Expand Down Expand Up @@ -245,7 +245,7 @@ fn test_struct_from_sequence() {
let yaml = indoc! {"
[0, 0]
"};
let expected = "invalid type: sequence, expected struct Struct at position 0";
let expected = "invalid type: sequence, expected struct Struct";
test_error::<Struct>(yaml, expected);
}

Expand Down Expand Up @@ -332,7 +332,7 @@ fn test_infinite_recursion_objects() {
}

let yaml = "&a {'x': *a}";
let expected = "recursion limit exceeded at position 0";
let expected = "recursion limit exceeded";
test_error::<S>(yaml, expected);
}

Expand All @@ -343,7 +343,7 @@ fn test_infinite_recursion_arrays() {
struct S(usize, Option<Box<S>>);

let yaml = "&a [0, *a]";
let expected = "recursion limit exceeded at position 0";
let expected = "recursion limit exceeded";
test_error::<S>(yaml, expected);
}

Expand All @@ -354,7 +354,7 @@ fn test_infinite_recursion_newtype() {
struct S(Option<Box<S>>);

let yaml = "&a [*a]";
let expected = "recursion limit exceeded at position 0";
let expected = "recursion limit exceeded";
test_error::<S>(yaml, expected);
}

Expand Down

0 comments on commit 1c031a6

Please sign in to comment.