Skip to content

Commit

Permalink
Rollup merge of #104416 - clubby789:fix-104414, r=eholk
Browse files Browse the repository at this point in the history
Fix using `include_bytes` in pattern position

Fix #104414
  • Loading branch information
matthiaskrgr committed Nov 21, 2022
2 parents 3278dea + 3652b89 commit 7a3eca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/proc-macro/expand-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}

0 comments on commit 7a3eca6

Please sign in to comment.