Skip to content

Commit 47b878b

Browse files
authored
fix(toml): Track dotted key for spans (#1118)
As this is just `toml`, this is for display purposes only and this can help with visualizing issues, see rust-lang/cargo#16600
2 parents 8447e2e + 87461d8 commit 47b878b

27 files changed

Lines changed: 1083 additions & 288 deletions

crates/toml/src/de/parser/key.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ fn more_key(input: &Input<'_>) -> bool {
8686

8787
struct State {
8888
current_key: Option<toml_parser::parser::Event>,
89+
start: usize,
8990
}
9091

9192
impl State {
9293
fn new(key_event: &toml_parser::parser::Event) -> Self {
9394
Self {
9495
current_key: Some(*key_event),
96+
start: key_event.span().start(),
9597
}
9698
}
9799

@@ -108,8 +110,9 @@ impl State {
108110
return;
109111
};
110112

111-
let key_span = key.span();
112-
let key_span = key_span.start()..key_span.end();
113+
let key_start = self.start;
114+
let key_end = key.span().end();
115+
let key_span = key_start..key_end;
113116

114117
let raw = source.get(key).unwrap();
115118
let mut decoded = alloc::borrow::Cow::Borrowed("");

0 commit comments

Comments
 (0)