Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Commit

Permalink
Update the remaining parts to Rust 1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed Apr 22, 2017
1 parent 6f7f55d commit d1b4781
Show file tree
Hide file tree
Showing 10 changed files with 667 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#![feature(naked_functions)]
#![feature(oom)]
#![feature(prelude_import)]
#![feature(pub_restricted)]
#![feature(rand)]
#![feature(raw)]
#![feature(shared)]
Expand Down
9 changes: 4 additions & 5 deletions src/libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ pub use linux::{socketpair, shutdown, symlink, unlink, write};
pub type off64_t = i64;
pub type mode_t = u32;

// Rust 1.15.0
// src/liblibc/src/unix/notbsd/linux/mod.rs
// Rust 1.16.0: src/liblibc/src/unix/notbsd/linux/mod.rs
#[cfg(issue = "22")]
pub const EAI_SYSTEM: c_int = -11;

Expand Down Expand Up @@ -105,19 +104,19 @@ pub unsafe fn lseek64(fd: c_int, offset: off64_t, whence: c_uint) -> off64_t {
}
}

// Rust 1.15.0: src/liblibc/src/unix/notbsd/mod.rs
// Rust 1.16.0: src/liblibc/src/unix/notbsd/mod.rs
#[allow(non_snake_case)]
pub fn WTERMSIG(status: c_int) -> c_int {
status & 0x7f
}

// Rust 1.15.0: src/liblibc/src/unix/notbsd/mod.rs
// Rust 1.16.0: src/liblibc/src/unix/notbsd/mod.rs
#[allow(non_snake_case)]
pub fn WIFEXITED(status: c_int) -> bool {
(status & 0x7f) == 0
}

// Rust 1.15.0: src/liblibc/src/unix/notbsd/mod.rs
// Rust 1.16.0: src/liblibc/src/unix/notbsd/mod.rs
#[allow(non_snake_case)]
pub fn WEXITSTATUS(status: c_int) -> c_int {
(status >> 8) & 0xff
Expand Down
60 changes: 57 additions & 3 deletions src/sys/linux/ext/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,38 @@ use sys_common::{FromInner, IntoInner, AsInner};
/// Unix-specific extensions to `OsString`.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStringExt {
/// Creates an `OsString` from a byte vector.
/// Creates an [`OsString`] from a byte vector.
///
/// # Examples
///
/// ```
/// use std::ffi::OsString;
/// use std::os::unix::ffi::OsStringExt;
///
/// let bytes = b"foo".to_vec();
/// let os_string = OsString::from_vec(bytes);
/// assert_eq!(os_string.to_str(), Some("foo"));
/// ```
///
/// [`OsString`]: ../../../ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
fn from_vec(vec: Vec<u8>) -> Self;

/// Yields the underlying byte vector of this `OsString`.
/// Yields the underlying byte vector of this [`OsString`].
///
/// # Examples
///
/// ```
/// use std::ffi::OsString;
/// use std::os::unix::ffi::OsStringExt;
///
/// let mut os_string = OsString::new();
/// os_string.push("foo");
/// let bytes = os_string.into_vec();
/// assert_eq!(bytes, b"foo");
/// ```
///
/// [`OsString`]: ../../../ffi/struct.OsString.html
#[stable(feature = "rust1", since = "1.0.0")]
fn into_vec(self) -> Vec<u8>;
}
Expand All @@ -43,9 +70,36 @@ impl OsStringExt for OsString {
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
#[stable(feature = "rust1", since = "1.0.0")]
/// Creates an [`OsStr`] from a byte slice.
///
/// # Examples
///
/// ```
/// use std::ffi::OsStr;
/// use std::os::unix::ffi::OsStrExt;
///
/// let bytes = b"foo";
/// let os_str = OsStr::from_bytes(bytes);
/// assert_eq!(os_str.to_str(), Some("foo"));
/// ```
///
/// [`OsStr`]: ../../../ffi/struct.OsStr.html
fn from_bytes(slice: &[u8]) -> &Self;

/// Gets the underlying byte view of the `OsStr` slice.
/// Gets the underlying byte view of the [`OsStr`] slice.
///
/// # Examples
///
/// ```
/// use std::ffi::OsStr;
/// use std::os::unix::ffi::OsStrExt;
///
/// let mut os_str = OsStr::new("foo");
/// let bytes = os_str.as_bytes();
/// assert_eq!(bytes, b"foo");
/// ```
///
/// [`OsStr`]: ../../../ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
fn as_bytes(&self) -> &[u8];
}
Expand Down
10 changes: 5 additions & 5 deletions src/sys/linux/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub trait PermissionsExt {
/// use std::fs::File;
/// use std::os::unix::fs::PermissionsExt;
///
/// let f = try!(File::create("foo.txt"));
/// let metadata = try!(f.metadata());
/// let f = File::create("foo.txt")?;
/// let metadata = f.metadata()?;
/// let permissions = metadata.permissions();
///
/// println!("permissions: {}", permissions.mode());
Expand All @@ -94,8 +94,8 @@ pub trait PermissionsExt {
/// use std::fs::File;
/// use std::os::unix::fs::PermissionsExt;
///
/// let f = try!(File::create("foo.txt"));
/// let metadata = try!(f.metadata());
/// let f = File::create("foo.txt")?;
/// let metadata = f.metadata()?;
/// let mut permissions = metadata.permissions();
///
/// permissions.set_mode(0o644); // Read/write for owner and read for others.
Expand Down Expand Up @@ -335,7 +335,7 @@ impl DirEntryExt for fs::DirEntry {
/// use std::os::unix::fs;
///
/// # fn foo() -> std::io::Result<()> {
/// try!(fs::symlink("a.txt", "b.txt"));
/// fs::symlink("a.txt", "b.txt")?;
/// # Ok(())
/// # }
/// ```
Expand Down
8 changes: 4 additions & 4 deletions src/sys/linux/ext/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Rust 1.15.0
// Rust 1.16.0
pub mod ffi;
// Rust 1.15.0
// Rust 1.16.0
pub mod fs;
// Rust 1.15.0
// Rust 1.16.0
pub mod io;
// Rust 1.15.0
// Rust 1.16.0 (no tests)
pub mod net;

#[stable(feature = "steed", since = "1.0.0")]
Expand Down
Loading

0 comments on commit d1b4781

Please sign in to comment.