tests: remove raw byte range syntax

This commit is contained in:
Tobias Schmitz 2025-05-20 15:09:22 +02:00
parent 506b64e2cd
commit 9c12c38a54
No known key found for this signature in database
2 changed files with 3 additions and 25 deletions

View File

@ -363,14 +363,11 @@ impl<'a> Parser<'a> {
}
let mut range = None;
if self.s.at('-') || self.s.at(char::is_numeric) || self.s.at('#') {
if self.s.at('-') || self.s.at(char::is_numeric) {
if let Some(file) = file {
range = self.parse_range_external(file);
} else if !self.s.at('#') {
range = self.parse_range(source);
} else {
self.error("raw byte positions are only allowed in external files");
return None;
range = self.parse_range(source);
}
if range.is_none() {
@ -413,20 +410,6 @@ impl<'a> Parser<'a> {
}
};
// Allow parsing of byte positions for external files.
if self.s.peek() == Some('#') {
let start = self.parse_byte_position()?;
let end =
if self.s.eat_if('-') { self.parse_byte_position()? } else { start };
if start < 0 || end < 0 {
self.error("byte positions must be positive");
return None;
}
return Some((start as usize)..(end as usize));
}
let start = self.parse_line_col()?;
let lines = Lines::from_bytes(text.as_ref()).expect("Errors shouldn't be annotated for files that aren't human readable (not valid utf-8)");
let range = if self.s.eat_if('-') {
@ -462,11 +445,6 @@ impl<'a> Parser<'a> {
Some(LineCol::one_based(line as usize, col as usize))
}
/// Parses a number after a `#` character.
fn parse_byte_position(&mut self) -> Option<isize> {
self.s.eat_if("#").then(|| self.parse_number()).flatten()
}
/// Parse a range, optionally abbreviated as just a position if the range
/// is empty.
fn parse_range(&mut self, source: &Source) -> Option<Range<usize>> {

View File

@ -37,7 +37,7 @@
))
--- toml-invalid ---
// Error: "/assets/data/bad.toml" #15-#16 failed to parse TOML (expected `.`, `=`)
// Error: "/assets/data/bad.toml" 1:16-2:1 failed to parse TOML (expected `.`, `=`)
#toml("/assets/data/bad.toml")
--- toml-decode-deprecated ---