tamer: parse::state::transition::TransitionResult::with_lookahead: {=>diagnostic_}panic!
As in previous commits, this continues to replace panics with `diagnostic_panic!`, which provides much more useful information both for debugging and to help the user possibly work around the problem. And lets the user know that it's not their fault, and it's a TAMER bug that should be reported. ...am I going to rationalize it in each commit message? DEV-13156main
parent
8cb4eb5b81
commit
a377261de3
|
@ -23,6 +23,7 @@ use super::{
|
|||
ClosedParseState, ParseState, ParseStateResult, ParseStatus,
|
||||
PartiallyStitchableParseState, StitchableParseState, Token,
|
||||
};
|
||||
use crate::{diagnose::Annotate, diagnostic_panic};
|
||||
use std::{
|
||||
convert::Infallible,
|
||||
hint::unreachable_unchecked,
|
||||
|
@ -91,10 +92,21 @@ impl<S: ParseState> TransitionResult<S> {
|
|||
// ever such a thing is deemed to be worth doing.
|
||||
Self(
|
||||
..,
|
||||
TransitionData::Result(_, Some(prev))
|
||||
| TransitionData::Dead(prev),
|
||||
TransitionData::Result(_, Some(Lookahead(prev)))
|
||||
| TransitionData::Dead(Lookahead(prev)),
|
||||
) => {
|
||||
panic!("internal error: lookahead token overwrite: {prev:?}")
|
||||
let desc = vec![
|
||||
prev.span().note("this token of lookahead would be lost"),
|
||||
lookahead.span().internal_error(
|
||||
"attempting to replace previous \
|
||||
lookahead token with this one",
|
||||
),
|
||||
];
|
||||
|
||||
diagnostic_panic!(
|
||||
desc,
|
||||
"cannot overwrite unused lookahead token"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue