Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement concat_bytes! #87599

Merged
merged 1 commit into from
Dec 9, 2021
Merged

Implement concat_bytes! #87599

merged 1 commit into from
Dec 9, 2021

Conversation

syvb
Copy link
Contributor

@syvb syvb commented Jul 29, 2021

This implements the unstable concat_bytes! macro, which has tracking issue #87555. It can be used like:

#![feature(concat_bytes)]

fn main() {
    assert_eq!(concat_bytes!(), &[]);
    assert_eq!(concat_bytes!(b'A', b"BC", [68, b'E', 70]), b"ABCDEF");
}

If strings or characters are used where byte strings or byte characters are required, it suggests adding a b prefix. If a number is used outside of an array it suggests arrayifying it. If a boolean is used it suggests replacing it with the numeric value of that number. Doubly nested arrays of bytes are disallowed.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2021
@Fishrock123
Copy link
Contributor

Just pointing out that the RFC contains a bit of a contradiction and this PR's tests don't appear to test that case: rust-lang/rfcs#2509 (comment)

@syvb
Copy link
Contributor Author

syvb commented Jul 29, 2021

@Fishrock123 That appears to have been an oversight when updating the RFC. I've added a test for it.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2021
@inquisitivecrystal inquisitivecrystal added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 24, 2021
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 19, 2021
@jackh726
Copy link
Member

Rerolling

r? rust-lang/compiler

compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/concat_bytes.rs Outdated Show resolved Hide resolved
library/core/src/macros/mod.rs Outdated Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2021
@JohnCSimon
Copy link
Member

Looks like this is ready for review
@rustbot label: -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 5, 2021
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 5, 2021
The tracking issue for this is rust-lang#87555.
@Mark-Simulacrum
Copy link
Member

Squashed commits, looks good to me, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 7, 2021

📌 Commit eb56693 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2021
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#87599 (Implement concat_bytes!)
 - rust-lang#89999 (Update std::env::temp_dir to use GetTempPath2 on Windows when available.)
 - rust-lang#90796 (Remove the reg_thumb register class for asm! on ARM)
 - rust-lang#91042 (Use Vec extend instead of repeated pushes on several places)
 - rust-lang#91634 (Do not attempt to suggest help for overly malformed struct/function call)
 - rust-lang#91685 (Install llvm tools to sysroot when assembling local toolchain)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3fc5bd7 into rust-lang:master Dec 9, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.