1
Fork 0

Fix an ICE parsing a malformed literal in concat_bytes!.

Fixes #104769.
This commit is contained in:
Nicholas Nethercote 2022-11-29 11:50:03 +11:00
parent 2585bcea0b
commit bf4a62c381
3 changed files with 29 additions and 1 deletions

View file

@ -2,6 +2,7 @@ use rustc_ast as ast;
use rustc_ast::{ptr::P, tokenstream::TokenStream};
use rustc_errors::Applicability;
use rustc_expand::base::{self, DummyResult};
use rustc_session::errors::report_lit_error;
use rustc_span::Span;
/// Emits errors for literal expressions that are invalid inside and outside of an array.
@ -68,7 +69,10 @@ fn invalid_type_err(
Ok(ast::LitKind::Int(_, _)) => {
cx.span_err(span, "numeric literal is not a `u8`");
}
_ => unreachable!(),
Ok(ast::LitKind::ByteStr(_) | ast::LitKind::Byte(_)) => unreachable!(),
Err(err) => {
report_lit_error(&cx.sess.parse_sess, err, token_lit, span);
}
}
}