Skip to content

Commit 47eda6b

Browse files
committed
Fix using include_bytes in pattern position
1 parent 96ddd32 commit 47eda6b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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"a" {
129+
include_bytes!("auxiliary/included-file.txt") => (),
130+
_ => ()
131+
}
132+
}

0 commit comments

Comments
 (0)