-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Define c_char using cfg_if rather than repeating 40-line cfg #91641
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup |
📌 Commit db5a2ae has been approved by |
Define c_char using cfg_if rather than repeating 40-line cfg Libstd has a 40-line cfg that defines the targets on which `c_char` is unsigned, and then repeats the same cfg with `not(…)` for the targets on which `c_char` is signed. This PR replaces it with a `cfg_if!` in which an `else` takes care of the signed case. I confirmed that `x.py doc library/std` inlines the type alias because c_char_definition is not a publicly accessible path: 
Looks like this caused a clippy test to fail in a rollup: #91650 (comment). The stderr now tells users to remove cast to |
I filed rust-lang/rust-clippy#8093 about the false positive and added a workaround in this PR. Tested by: //#[cfg(all())] // unnecessary_cast goes away if uncommented
type T = u8;
fn main() {
let _ = 0 as T;
} |
@bors r+ |
📌 Commit 4e8b91a has been approved by |
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#91641 (Define c_char using cfg_if rather than repeating 40-line cfg) - rust-lang#92899 (Mention std::iter::zip in Iterator::zip docs) - rust-lang#93193 (Add test for stable hash uniqueness of adjacent field values) - rust-lang#93325 (Introduce a limit to Levenshtein distance computation) - rust-lang#93339 (rustdoc: add test case for multiple traits and erased names) - rust-lang#93357 (Clarify the `usage-of-qualified-ty` error message.) - rust-lang#93363 (`#[rustc_pass_by_value]` cleanup) - rust-lang#93365 (More arena cleanups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Libstd has a 40-line cfg that defines the targets on which
c_char
is unsigned, and then repeats the same cfg withnot(…)
for the targets on whichc_char
is signed.This PR replaces it with a
cfg_if!
in which anelse
takes care of the signed case.I confirmed that
x.py doc library/std
inlines the type alias because c_char_definition is not a publicly accessible path: