diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 04fe6c4007e94..bdcd53349492c 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -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, diff --git a/src/test/ui/proc-macro/expand-expr.rs b/src/test/ui/proc-macro/expand-expr.rs index 8d51b7e17185b..901b3a951023c 100644 --- a/src/test/ui/proc-macro/expand-expr.rs +++ b/src/test/ui/proc-macro/expand-expr.rs @@ -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"), + } +}