Rollup merge of #104416 - clubby789:fix-104414, r=eholk

Fix using `include_bytes` in pattern position

Fix #104414
This commit is contained in:
Matthias Krüger 2022-11-22 00:01:07 +01:00 committed by GitHub
commit 7a3eca690f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -507,7 +507,7 @@ impl MacResult for MacEager {
return Some(p);
}
if let Some(e) = self.expr {
if let ast::ExprKind::Lit(_) = e.kind {
if matches!(e.kind, ast::ExprKind::Lit(_) | ast::ExprKind::IncludedBytes(_)) {
return Some(P(ast::Pat {
id: ast::DUMMY_NODE_ID,
span: e.span,

View File

@ -123,4 +123,10 @@ expand_expr_fail!(echo_pm!(arbitrary_expression() + "etc"));
const _: u32 = recursive_expand!(); //~ ERROR: recursion limit reached while expanding `recursive_expand!`
fn main() {}
fn main() {
// https://github.com/rust-lang/rust/issues/104414
match b"Included file contents\n" {
include_bytes!("auxiliary/included-file.txt") => (),
_ => panic!("include_bytes! in pattern"),
}
}