Skip to content

Commit 7a3eca6

Browse files
authored
Rollup merge of #104416 - clubby789:fix-104414, r=eholk
Fix using `include_bytes` in pattern position Fix #104414
2 parents 3278dea + 3652b89 commit 7a3eca6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/rustc_expand/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl MacResult for MacEager {
507507
return Some(p);
508508
}
509509
if let Some(e) = self.expr {
510-
if let ast::ExprKind::Lit(_) = e.kind {
510+
if matches!(e.kind, ast::ExprKind::Lit(_) | ast::ExprKind::IncludedBytes(_)) {
511511
return Some(P(ast::Pat {
512512
id: ast::DUMMY_NODE_ID,
513513
span: e.span,

src/test/ui/proc-macro/expand-expr.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,10 @@ expand_expr_fail!(echo_pm!(arbitrary_expression() + "etc"));
123123

124124
const _: u32 = recursive_expand!(); //~ ERROR: recursion limit reached while expanding `recursive_expand!`
125125

126-
fn main() {}
126+
fn main() {
127+
// https://github.com/rust-lang/rust/issues/104414
128+
match b"Included file contents\n" {
129+
include_bytes!("auxiliary/included-file.txt") => (),
130+
_ => panic!("include_bytes! in pattern"),
131+
}
132+
}

0 commit comments

Comments
 (0)