Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Omit line number for toml parse error for unknown spans
In the case that the span is (0..0), we don't usually know where the
error really occurred. In that case just omit the line number.

Resolves: #2189

This error is tracked upstream:

* toml: toml-rs/toml#589
* serde: serde-rs/serde#1183
  • Loading branch information
bim9262 committed Aug 19, 2025
commit fc36af302b25b79cf3d1798e2c584a2df03c9036
14 changes: 9 additions & 5 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ where
let location_msg = err
.span()
.map(|span| {
let line = 1 + contents.as_bytes()[..(span.start)]
.iter()
.filter(|b| **b == b'\n')
.count();
format!(" at line {line}")
if span == (0..0) {
String::new()
} else {
let line = 1 + contents.as_bytes()[..(span.start)]
.iter()
.filter(|b| **b == b'\n')
.count();
format!(" at line {line}")
}
})
.unwrap_or_default();
Error::new(format!(
Expand Down