Skip to content

Commit

Permalink
Add ErrorGuaranteed to DestructuredFloat::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
ShE3py committed Aug 6, 2024
1 parent 93ea767 commit a9fbb22
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum DestructuredFloat {
/// 1.2 | 1.2e3
MiddleDot(Symbol, Span, Span, Symbol, Span),
/// Invalid
Error,
Error(ErrorGuaranteed),
}

impl<'a> Parser<'a> {
Expand Down Expand Up @@ -989,7 +989,7 @@ impl<'a> Parser<'a> {
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,
})
}
_ => {
Expand All @@ -999,7 +999,7 @@ impl<'a> Parser<'a> {
}
}

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();
Expand All @@ -1009,7 +1009,7 @@ impl<'a> Parser<'a> {
}
_ => (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.
Expand Down Expand Up @@ -1097,8 +1097,8 @@ impl<'a> Parser<'a> {
// 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:?}"),
}
Expand Down Expand Up @@ -1164,7 +1164,7 @@ impl<'a> Parser<'a> {
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));
}
Expand Down

0 comments on commit a9fbb22

Please sign in to comment.