Skip to content

Commit 597d9e4

Browse files
committed
Auto merge of rust-lang#155755 - JonathanBrouwer:rollup-oG1Wz3V, r=JonathanBrouwer
Rollup of 3 pull requests Successful merges: - rust-lang#155754 (make the `core::ffi::va_list` module private) - rust-lang#155522 (cmse: test returning `MaybeUninit<T>`) - rust-lang#155741 (std: Refactor BufWriter::flush to use the `?` operator)
2 parents 80729d7 + 6f536cf commit 597d9e4

7 files changed

Lines changed: 63 additions & 13 deletions

File tree

library/core/src/ffi/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,14 @@ use crate::fmt;
2323
#[stable(feature = "c_str_module", since = "1.88.0")]
2424
pub mod c_str;
2525

26+
mod va_list;
2627
#[unstable(
2728
feature = "c_variadic",
2829
issue = "44930",
2930
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
3031
)]
3132
pub use self::va_list::{VaArgSafe, VaList};
3233

33-
#[unstable(
34-
feature = "c_variadic",
35-
issue = "44930",
36-
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
37-
)]
38-
pub mod va_list;
39-
4034
mod primitives;
4135
#[stable(feature = "core_ffi_c", since = "1.64.0")]
4236
pub use self::primitives::{

library/core/src/ffi/va_list.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
//!
33
//! Better known as "varargs".
44
5+
#![unstable(
6+
feature = "c_variadic",
7+
issue = "44930",
8+
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
9+
)]
10+
511
#[cfg(not(target_arch = "xtensa"))]
612
use crate::ffi::c_void;
713
use crate::fmt;

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
issue = "none"
5454
)]
5555

56-
use crate::ffi::va_list::{VaArgSafe, VaList};
56+
use crate::ffi::{VaArgSafe, VaList};
5757
use crate::marker::{ConstParamTy, DiscriminantKind, PointeeSized, Tuple};
5858
use crate::{mem, ptr};
5959

library/std/src/io/buffered/bufwriter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ impl<W: ?Sized + Write> Write for BufWriter<W> {
641641
}
642642

643643
fn flush(&mut self) -> io::Result<()> {
644-
self.flush_buf().and_then(|()| self.get_mut().flush())
644+
self.flush_buf()?;
645+
self.get_mut().flush()
645646
}
646647
}
647648

tests/auxiliary/minicore.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
decl_macro,
2828
f16,
2929
f128,
30+
transparent_unions,
3031
asm_experimental_arch,
3132
unboxed_closures
3233
)]
@@ -127,6 +128,25 @@ pub struct ManuallyDrop<T: PointeeSized> {
127128
}
128129
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
129130

131+
#[lang = "maybe_uninit"]
132+
#[repr(transparent)]
133+
pub union MaybeUninit<T> {
134+
uninit: (),
135+
value: ManuallyDrop<T>,
136+
}
137+
138+
impl<T: Copy + PointeeSized> Copy for MaybeUninit<T> {}
139+
140+
impl<T> MaybeUninit<T> {
141+
pub const fn uninit() -> Self {
142+
Self { uninit: () }
143+
}
144+
145+
pub const fn new(value: T) -> Self {
146+
Self { value: ManuallyDrop { value } }
147+
}
148+
}
149+
130150
#[repr(transparent)]
131151
#[rustc_nonnull_optimization_guaranteed]
132152
pub struct NonNull<T: ?Sized> {

tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,25 @@ struct Test {
4242
i128: extern "cmse-nonsecure-call" fn() -> i128, //~ ERROR [E0798]
4343
}
4444

45-
#[repr(C)]
46-
pub union ReprCUnionU64 {
45+
#[repr(Rust)]
46+
pub union ReprRustUnionU64 {
4747
_unused: u64,
4848
}
4949

50-
#[repr(Rust)]
51-
pub union ReprRustUnionU64 {
50+
#[repr(C)]
51+
pub union ReprCUnionU64 {
5252
_unused: u64,
5353
}
5454

5555
#[no_mangle]
5656
pub fn test_union(
5757
f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, //~ ERROR [E0798]
5858
f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, //~ ERROR [E0798]
59+
60+
// MaybeUninit is a transparent union, and hence MaybeUninit<u64> is abi-compatible with u64,
61+
// and thus allowed as a return type.
62+
f3: extern "cmse-nonsecure-call" fn() -> MaybeUninit<u32>,
63+
f4: extern "cmse-nonsecure-call" fn() -> MaybeUninit<u64>,
64+
f5: extern "cmse-nonsecure-call" fn() -> MaybeUninit<f64>,
5965
) {
6066
}

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,26 @@ pub extern "cmse-nonsecure-entry" fn four(_: Four) {}
4545

4646
#[no_mangle]
4747
pub extern "cmse-nonsecure-entry" fn five(_: Five) {} //~ ERROR [E0798]
48+
49+
#[repr(Rust)]
50+
pub union ReprRustUnionU64 {
51+
_unused: u64,
52+
}
53+
54+
#[repr(C)]
55+
pub union ReprCUnionU64 {
56+
_unused: u64,
57+
}
58+
59+
#[no_mangle]
60+
#[allow(improper_ctypes_definitions)]
61+
pub extern "cmse-nonsecure-entry" fn union_rust(_: ReprRustUnionU64) {}
62+
63+
#[no_mangle]
64+
pub extern "cmse-nonsecure-entry" fn union_c(_: ReprCUnionU64) {}
65+
66+
#[no_mangle]
67+
pub extern "cmse-nonsecure-entry" fn maybe_uninit_32bit(_: MaybeUninit<u32>) {}
68+
69+
#[no_mangle]
70+
pub extern "cmse-nonsecure-entry" fn maybe_uninit_64bit(_: MaybeUninit<f64>) {}

0 commit comments

Comments
 (0)