Add ErrorGuaranteed to DestructuredFloat::Error

This commit is contained in:
Lieselotte 2024-09-14 12:16:23 +02:00
parent f9567d0f2b
commit 003da02352
No known key found for this signature in database
GPG Key ID: 68A9A951C7E1F283

View File

@ -49,7 +49,7 @@ enum DestructuredFloat {
/// 1.2 | 1.2e3
MiddleDot(Symbol, Span, Span, Symbol, Span),
/// Invalid
Error,
Error(ErrorGuaranteed),
}
impl<'a> Parser<'a> {
@ -1008,7 +1008,7 @@ pub(super) fn parse_dot_suffix_expr(
self.mk_expr_tuple_field_access(lo, ident1_span, base, sym1, None);
self.mk_expr_tuple_field_access(lo, ident2_span, base1, sym2, suffix)
}
DestructuredFloat::Error => base,
DestructuredFloat::Error(_) => base,
})
}
_ => {
@ -1018,7 +1018,7 @@ pub(super) fn parse_dot_suffix_expr(
}
}
fn error_unexpected_after_dot(&self) {
fn error_unexpected_after_dot(&self) -> ErrorGuaranteed {
let actual = pprust::token_to_string(&self.token);
let span = self.token.span;
let sm = self.psess.source_map();
@ -1028,7 +1028,7 @@ fn error_unexpected_after_dot(&self) {
}
_ => (span, actual),
};
self.dcx().emit_err(errors::UnexpectedTokenAfterDot { span, actual });
self.dcx().emit_err(errors::UnexpectedTokenAfterDot { span, actual })
}
// We need an identifier or integer, but the next token is a float.
@ -1116,8 +1116,8 @@ enum FloatComponent {
// 1.2e+3 | 1.2e-3
[IdentLike(_), Punct('.'), IdentLike(_), Punct('+' | '-'), IdentLike(_)] => {
// See the FIXME about `TokenCursor` above.
self.error_unexpected_after_dot();
DestructuredFloat::Error
let guar = self.error_unexpected_after_dot();
DestructuredFloat::Error(guar)
}
_ => panic!("unexpected components in a float token: {components:?}"),
}
@ -1183,7 +1183,7 @@ fn parse_floating_field_access(&mut self) -> PResult<'a, P<[Ident]>> {
fields.insert(start_idx, Ident::new(symbol2, span2));
fields.insert(start_idx, Ident::new(symbol1, span1));
}
DestructuredFloat::Error => {
DestructuredFloat::Error(_) => {
trailing_dot = None;
fields.insert(start_idx, Ident::new(symbol, self.prev_token.span));
}