From 47eda6b7dbca58eec691bc9faf95791d9379ccbe Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 14 Nov 2022 17:43:21 +0000
Subject: [PATCH 1/2] Fix using `include_bytes` in pattern position

---
 compiler/rustc_expand/src/base.rs     | 2 +-
 src/test/ui/proc-macro/expand-expr.rs | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs
index 1294f1e17d412..6cad8cb843f5e 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..75a23976a6489 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"a" {
+        include_bytes!("auxiliary/included-file.txt") => (),
+        _ => ()
+    }
+}

From 3652b89f85cd32d47f46f71934d054fc5cf5c2f8 Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 14 Nov 2022 19:44:30 +0000
Subject: [PATCH 2/2] Update src/test/ui/proc-macro/expand-expr.rs

Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
---
 src/test/ui/proc-macro/expand-expr.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/ui/proc-macro/expand-expr.rs b/src/test/ui/proc-macro/expand-expr.rs
index 75a23976a6489..901b3a951023c 100644
--- a/src/test/ui/proc-macro/expand-expr.rs
+++ b/src/test/ui/proc-macro/expand-expr.rs
@@ -125,8 +125,8 @@ const _: u32 = recursive_expand!(); //~ ERROR: recursion limit reached while exp
 
 fn main() {
     // https://github.com/rust-lang/rust/issues/104414
-    match b"a" {
+    match b"Included file contents\n" {
         include_bytes!("auxiliary/included-file.txt") => (),
-        _ => ()
+        _ => panic!("include_bytes! in pattern"),
     }
 }