about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/concat_bytes.rs
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2022-10-31 18:30:09 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2022-11-11 16:31:32 +0000
commitb2da155a9aae875e6c2f5df52d8f87e734c88be7 (patch)
tree293570eff93ac9268712b67a03fd85fdf19fe978 /compiler/rustc_builtin_macros/src/concat_bytes.rs
parentb7b7f2716ee1655a696d3d64c3e12638d0dd19c0 (diff)
downloadrust-b2da155a9aae875e6c2f5df52d8f87e734c88be7.tar.gz
rust-b2da155a9aae875e6c2f5df52d8f87e734c88be7.zip
Introduce `ExprKind::IncludedBytes`
Diffstat (limited to 'compiler/rustc_builtin_macros/src/concat_bytes.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/concat_bytes.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs
index 66e86bf2182..4886ca786a5 100644
--- a/compiler/rustc_builtin_macros/src/concat_bytes.rs
+++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs
@@ -108,6 +108,16 @@ fn handle_array_element(
                 None
             }
         },
+        ast::ExprKind::IncludedBytes(..) => {
+            if !*has_errors {
+                cx.struct_span_err(expr.span, "cannot concatenate doubly nested array")
+                    .note("byte strings are treated as arrays of bytes")
+                    .help("try flattening the array")
+                    .emit();
+            }
+            *has_errors = true;
+            None
+        }
         _ => {
             missing_literals.push(expr.span);
             None
@@ -167,6 +177,9 @@ pub fn expand_concat_bytes(
                     has_errors = true;
                 }
             },
+            ast::ExprKind::IncludedBytes(ref bytes) => {
+                accumulator.extend_from_slice(bytes);
+            }
             ast::ExprKind::Err => {
                 has_errors = true;
             }