Skip to content

Commit a6008fa

Browse files
committed
Auto merge of #77090 - rust-lang:revert-76110-convert-openoptions-cint, r=dtolnay
Revert "Function to convert OpenOptions to c_int" Reverts #76110. This broke Rust's stability guarantees. Closes #77089. r? `@joshtriplett`
2 parents 33aa8be + 15f08d6 commit a6008fa

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

library/std/src/sys/unix/ext/fs.rs

-29
Original file line numberDiff line numberDiff line change
@@ -348,31 +348,6 @@ pub trait OpenOptionsExt {
348348
/// ```
349349
#[stable(feature = "open_options_ext", since = "1.10.0")]
350350
fn custom_flags(&mut self, flags: i32) -> &mut Self;
351-
352-
/// Get the flags as [`libc::c_int`].
353-
///
354-
/// This method allows the reuse of the OpenOptions as flags argument for [`libc::open`].
355-
///
356-
/// [`libc::c_int`]: https://docs.rs/libc/*/libc/type.c_int.html
357-
/// [`libc::open`]: https://docs.rs/libc/*/libc/fn.open.html
358-
///
359-
/// # Examples
360-
///
361-
/// ```no_run
362-
/// # #![feature(rustc_private)]
363-
/// #![feature(open_options_ext_as_flags)]
364-
/// extern crate libc;
365-
/// use std::ffi::CString;
366-
/// use std::fs::OpenOptions;
367-
/// use std::os::unix::fs::OpenOptionsExt;
368-
///
369-
/// let mut options = OpenOptions::new();
370-
/// options.write(true).read(true);
371-
/// let file_name = CString::new("foo.txt").unwrap();
372-
/// let file = unsafe { libc::open(file_name.as_c_str().as_ptr(), options.as_flags().unwrap()) };
373-
/// ```
374-
#[unstable(feature = "open_options_ext_as_flags", issue = "76801")]
375-
fn as_flags(&self) -> io::Result<libc::c_int>;
376351
}
377352

378353
#[stable(feature = "fs_ext", since = "1.1.0")]
@@ -386,10 +361,6 @@ impl OpenOptionsExt for OpenOptions {
386361
self.as_inner_mut().custom_flags(flags);
387362
self
388363
}
389-
390-
fn as_flags(&self) -> io::Result<libc::c_int> {
391-
self.as_inner().as_flags()
392-
}
393364
}
394365

395366
/// Unix-specific extensions to [`fs::Metadata`].

library/std/src/sys/unix/fs.rs

-6
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,6 @@ impl OpenOptions {
656656
self.mode = mode as mode_t;
657657
}
658658

659-
pub fn as_flags(&self) -> io::Result<c_int> {
660-
let access_mode = self.get_access_mode()?;
661-
let creation_mode = self.get_creation_mode()?;
662-
Ok(creation_mode | access_mode | self.custom_flags)
663-
}
664-
665659
fn get_access_mode(&self) -> io::Result<c_int> {
666660
match (self.read, self.write, self.append) {
667661
(true, false, false) => Ok(libc::O_RDONLY),

0 commit comments

Comments
 (0)