show preceding comment in test panic messages

This commit is contained in:
Folkert 2022-07-19 20:32:35 +02:00 committed by Richard Feldman
parent 5a93da5a11
commit 2caf58dfd2
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
2 changed files with 20 additions and 5 deletions

View file

@ -626,6 +626,21 @@ fn parse_defs_end<'a>(
let end = loc_def_expr.region.end();
let region = Region::new(start, end);
// drop newlines before the preceding comment
let spaces_before_start = spaces_before_current_start.offset as usize;
let spaces_before_end = start.offset as usize;
let mut spaces_before_current_start = spaces_before_current_start;
for byte in &state.original_bytes()[spaces_before_start..spaces_before_end]
{
match byte {
b' ' | b'\n' => {
spaces_before_current_start.offset += 1;
}
_ => break,
}
}
let preceding_comment = Region::new(spaces_before_current_start, start);
let value_def = ValueDef::Expect {