Default RawOsError to i16 for 16-bit targets - #160543
Conversation
|
r? @Darksonn rustbot has assigned @Darksonn. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Sorry I'm at capacity for the next two weeks. @rustbot reroll |
|
Clar I don't know why RustBot keeps giving you my PRs but hello again! |
74b8b44 to
9b6ba41
Compare
RawOsError to c_int instead of i32RawOsError to i16 for 16-bit targets
This comment has been minimized.
This comment has been minimized.
9b6ba41 to
bbc212a
Compare
| #[test] | ||
| fn raw_os_error_ffi_guarantees() { | ||
| let _: RawOsError = cfg_select! { | ||
| target_os = "uefi" => 0 as usize, |
There was a problem hiding this comment.
well, the test already declare that.
There was a problem hiding this comment.
Yeah tgross35's suggestion to use explicitly sized types is compared against the c_int assumption just so if a target is ever added that violates it, we know about it.
There was a problem hiding this comment.
Fwiw I was thinking to put it in a `const _: () = { /* ... */ } so the tests don't actually have to be run (I don't think we run coretests on these 16-bit platforms), but it doesn't matter much
There was a problem hiding this comment.
Yeah I'm not a huge fan of that particular const trick. The test as written is still compile-time evaluated, it'll just hopefully give a nicer message if/when it fails.
ACP: rust-lang/libs-team#755
Tracking issue: #154046 & #107792
Fixes #160541
Description
As noted by @tgross35, it's likely desirable for
RawOsErrorto default toi16for 16-bit platforms. Practically, this only affects AVR and MSP430. Sincec_intis defined as:This also ensures for all platforms (excluding UEFI),
RawOsErroris equivalent toc_int. Since neither sets of targets had an implementation ofstd, this hasn't yet been litigated. WhileRawOsErroris unstable, it seems reasonable to choose a default more likely to align with the underlying OS (if any).Notes