Skip to main content

syntax_error_position

Function syntax_error_position 

Source
pub fn syntax_error_position(
    input: &str,
    backslash_escapes: bool,
    token_pos: usize,
) -> Option<usize>
Expand description

v7.39 (read01 round 95) — recover PG’s 1-based CHARACTER error position for a ParseError::token_pos. Kept off the ParseError struct (and so off every recursive Result slot) to protect the nesting-budget frame cliff: this re-tokenizes input on the cold error path to map the failing token index to its start byte, then to a character offset. backslash_escapes must match the parse that produced token_pos (it barely shifts offsets, but stay consistent). Returns None when the index has no offset or the byte isn’t a char boundary. The wire attaches it as the ErrorResponse P.