about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-02 12:38:41 +0000
committerbors <bors@rust-lang.org>2022-01-02 12:38:41 +0000
commit03360be6b77a37947e6ef6c54777b7b96728de69 (patch)
tree047711077b715a63ef65d23cd67ee51516b0c4e0 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent82418f93ac70c2de31843dbe7c0e7d2174636688 (diff)
parent9702348957083e1104776edcf897ca1808364869 (diff)
downloadrust-03360be6b77a37947e6ef6c54777b7b96728de69.tar.gz
rust-03360be6b77a37947e6ef6c54777b7b96728de69.zip
Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisa
Support [x; n] expressions in concat_bytes!

Currently trying to use `concat_bytes!` with a repeating array value like `[42; 5]` results in an error:
```
error: expected a byte literal
 --> src/main.rs:3:27
  |
3 |     let x = concat_bytes!([3; 4]);
  |                           ^^^^^^
  |
  = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()`
```

This makes it so repeating array syntax can be used the same way normal arrays can be. The RFC doesn't explicitly mention repeat expressions, but it seems reasonable to allow them as well, since normal arrays are allowed.

It is possible to make the compiler get stuck compiling forever with `concat_bytes!([3; 999999999])`, but I don't think that's much of an issue since you can do that already with `const X: [u8; 999999999] = [3; 999999999];`.

Contributes to #87555.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions