Skip to content

Commit ae30294

Browse files
committed
Remove raw pointer from OpenOptions struct
Otherwise it is not Send and Sync anymore
1 parent 9c56918 commit ae30294

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/libstd/fs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,12 @@ mod tests {
22642264
assert_eq!(check!(fs::metadata(&tmpdir.join("h"))).len(), 9);
22652265
}
22662266

2267+
#[test]
2268+
fn _assert_send_sync() {
2269+
fn _assert_send_sync<T: Send + Sync>() {}
2270+
_assert_send_sync::<OpenOptions>();
2271+
}
2272+
22672273
#[test]
22682274
fn binary_file() {
22692275
let mut bytes = [0; 1024];

src/libstd/sys/windows/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct OpenOptions {
6969
attributes: c::DWORD,
7070
share_mode: c::DWORD,
7171
security_qos_flags: c::DWORD,
72-
security_attributes: c::LPSECURITY_ATTRIBUTES,
72+
security_attributes: usize, // FIXME: should be a reference
7373
}
7474

7575
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -170,7 +170,7 @@ impl OpenOptions {
170170
share_mode: c::FILE_SHARE_READ | c::FILE_SHARE_WRITE | c::FILE_SHARE_DELETE,
171171
attributes: 0,
172172
security_qos_flags: 0,
173-
security_attributes: ptr::null_mut(),
173+
security_attributes: 0,
174174
}
175175
}
176176

@@ -187,7 +187,7 @@ impl OpenOptions {
187187
pub fn attributes(&mut self, attrs: u32) { self.attributes = attrs; }
188188
pub fn security_qos_flags(&mut self, flags: u32) { self.security_qos_flags = flags; }
189189
pub fn security_attributes(&mut self, attrs: c::LPSECURITY_ATTRIBUTES) {
190-
self.security_attributes = attrs;
190+
self.security_attributes = attrs as usize;
191191
}
192192

193193
fn get_access_mode(&self) -> io::Result<c::DWORD> {

0 commit comments

Comments
 (0)