Add ErrorGuaranteed
to DestructuredFloat::Error
This commit is contained in:
parent
f9567d0f2b
commit
003da02352
@ -49,7 +49,7 @@ 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,
|
Error(ErrorGuaranteed),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
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, 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -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 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();
|
||||||
@ -1028,7 +1028,7 @@ fn error_unexpected_after_dot(&self) {
|
|||||||
}
|
}
|
||||||
_ => (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.
|
||||||
@ -1116,8 +1116,8 @@ enum FloatComponent {
|
|||||||
// 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.
|
||||||
self.error_unexpected_after_dot();
|
let guar = self.error_unexpected_after_dot();
|
||||||
DestructuredFloat::Error
|
DestructuredFloat::Error(guar)
|
||||||
}
|
}
|
||||||
_ => panic!("unexpected components in a float token: {components:?}"),
|
_ => 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(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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user