Remove ErrorGuaranteed retval from error_unexpected_after_dot.

It was added in #130349, but it's not used meaningfully, and causes
difficulties for Nonterminal removal in #124141.
This commit is contained in:
Nicholas Nethercote 2024-09-20 13:02:14 +10:00
parent cee88f7a3f
commit 03159d4bff

View File

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