Skip to content

Commit 2e33717

Browse files
committed
Rollup merge of rust-lang#24216 - alexcrichton:stabilize-from-raw-os-error, r=aturon
This commit stabilizes the old `io::Error::from_os_error` after being renamed to use the `raw_os_error` terminology instead. This function is often useful when writing bindings to OS functions but only actually converting to an I/O error at a later point.
2 parents 1674c32 + 561fdec commit 2e33717

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/libstd/io/error.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,18 @@ impl Error {
163163
/// `Error` for the error code.
164164
#[stable(feature = "rust1", since = "1.0.0")]
165165
pub fn last_os_error() -> Error {
166-
Error::from_os_error(sys::os::errno() as i32)
166+
Error::from_raw_os_error(sys::os::errno() as i32)
167167
}
168168

169169
/// Creates a new instance of an `Error` from a particular OS error code.
170-
#[unstable(feature = "io",
171-
reason = "unclear whether this function is necessary")]
170+
#[stable(feature = "rust1", since = "1.0.0")]
171+
pub fn from_raw_os_error(code: i32) -> Error {
172+
Error { repr: Repr::Os(code) }
173+
}
174+
175+
/// Creates a new instance of an `Error` from a particular OS error code.
176+
#[unstable(feature = "io", reason = "deprecated")]
177+
#[deprecated(since = "1.0.0", reason = "renamed to from_raw_os_error")]
172178
pub fn from_os_error(code: i32) -> Error {
173179
Error { repr: Repr::Os(code) }
174180
}

src/libstd/sys/unix/process2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Process {
193193
let errno = combine(&bytes[0.. 4]);
194194
assert!(p.wait().is_ok(),
195195
"wait() should either return Ok or panic");
196-
return Err(Error::from_os_error(errno))
196+
return Err(Error::from_raw_os_error(errno))
197197
}
198198
Ok(0) => return Ok(p),
199199
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}

src/libstd/sys/unix/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub unsafe fn create(stack: usize, p: Thunk) -> io::Result<rust_thread> {
212212
assert_eq!(pthread_attr_destroy(&mut attr), 0);
213213

214214
return if ret != 0 {
215-
Err(io::Error::from_os_error(ret))
215+
Err(io::Error::from_raw_os_error(ret))
216216
} else {
217217
mem::forget(p); // ownership passed to pthread_create
218218
Ok(native)

src/libstd/sys/windows/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn init() {
4343

4444
/// Returns the last error from the Windows socket interface.
4545
fn last_error() -> io::Error {
46-
io::Error::from_os_error(unsafe { c::WSAGetLastError() })
46+
io::Error::from_raw_os_error(unsafe { c::WSAGetLastError() })
4747
}
4848

4949
/// Checks if the signed integer is the Windows constant `SOCKET_ERROR` (-1)

0 commit comments

Comments
 (0)