diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2022-11-14 17:43:21 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2022-11-14 17:43:21 +0000 |
| commit | 47eda6b7dbca58eec691bc9faf95791d9379ccbe (patch) | |
| tree | 7d9f959977d7b3d9835978a61f44b92ce917763a | |
| parent | 96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef (diff) | |
| download | rust-47eda6b7dbca58eec691bc9faf95791d9379ccbe.tar.gz rust-47eda6b7dbca58eec691bc9faf95791d9379ccbe.zip | |
Fix using `include_bytes` in pattern position
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 2 | ||||
| -rw-r--r-- | 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 1294f1e17d4..6cad8cb843f 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 8d51b7e1718..75a23976a64 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") => (), + _ => () + } +} |
