1
Fork 0

Auto merge of #43316 - Mark-Simulacrum:rollup, r=Mark-Simulacrum

Rollup of 11 pull requests

- Successful merges: #42837, #43282, #43287, #43290, #43292, #43294, #43304, #43310, #43312, #43314, #43315
- Failed merges:
This commit is contained in:
bors 2017-07-18 21:59:01 +00:00
commit af049cd08b
23 changed files with 209 additions and 176 deletions

View file

@ -11,7 +11,82 @@ git:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
# Linux builders, all docker images # Images used in testing PR and try-build should be run first.
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1
- env: IMAGE=dist-x86_64-linux DEPLOY=1 ALLOW_TRY=1
# "alternate" deployments, these are "nightlies" but don't have assertions
# turned on, they're deployed to a different location primarily for projects
# which are stuck on nightly and don't want llvm assertions in the artifacts
# that they use.
- env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler"
SRC=.
DEPLOY_ALT=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
# macOS builders. These are placed near the beginning because they are very
# slow to run.
# OSX builders running tests, these run the full test suite.
#
# Note that the compiler is compiled to target 10.8 here because the Xcode
# version that we're using, 8.2, cannot compile LLVM for OSX 10.7.
- env: >
RUST_CHECK_TARGET=check
RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler"
SRC=.
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.8
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
- env: >
RUST_CHECK_TARGET=check
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
SRC=.
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.8
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
# OSX builders producing releases. These do not run the full test suite and
# just produce a bunch of artifacts.
#
# Note that these are running in the `xcode7` image instead of the
# `xcode8.2` image as above. That's because we want to build releases for
# OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7.
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-extended --enable-profiler"
SRC=.
DEPLOY=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended --enable-sanitizers --enable-profiler"
SRC=.
DEPLOY=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
# Linux builders, remaining docker images
- env: IMAGE=arm-android - env: IMAGE=arm-android
- env: IMAGE=armhf-gnu - env: IMAGE=armhf-gnu
- env: IMAGE=cross DEPLOY=1 - env: IMAGE=cross DEPLOY=1
@ -33,7 +108,6 @@ matrix:
- env: IMAGE=dist-powerpc64le-linux DEPLOY=1 - env: IMAGE=dist-powerpc64le-linux DEPLOY=1
- env: IMAGE=dist-s390x-linux DEPLOY=1 - env: IMAGE=dist-s390x-linux DEPLOY=1
- env: IMAGE=dist-x86_64-freebsd DEPLOY=1 - env: IMAGE=dist-x86_64-freebsd DEPLOY=1
- env: IMAGE=dist-x86_64-linux DEPLOY=1 ALLOW_TRY=1
- env: IMAGE=dist-x86_64-musl DEPLOY=1 - env: IMAGE=dist-x86_64-musl DEPLOY=1
- env: IMAGE=dist-x86_64-netbsd DEPLOY=1 - env: IMAGE=dist-x86_64-netbsd DEPLOY=1
- env: IMAGE=asmjs - env: IMAGE=asmjs
@ -45,96 +119,9 @@ matrix:
- env: IMAGE=x86_64-gnu-aux - env: IMAGE=x86_64-gnu-aux
- env: IMAGE=x86_64-gnu-debug - env: IMAGE=x86_64-gnu-debug
- env: IMAGE=x86_64-gnu-nopt - env: IMAGE=x86_64-gnu-nopt
- env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1
- env: IMAGE=x86_64-gnu-distcheck - env: IMAGE=x86_64-gnu-distcheck
- env: IMAGE=x86_64-gnu-incremental - env: IMAGE=x86_64-gnu-incremental
# OSX builders running tests, these run the full test suite.
#
# Note that the compiler is compiled to target 10.8 here because the Xcode
# version that we're using, 8.2, cannot compile LLVM for OSX 10.7.
- env: >
RUST_CHECK_TARGET=check
RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler"
SRC=.
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.8
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
install: &osx_install_sccache >
travis_retry curl -fo /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin &&
chmod +x /usr/local/bin/sccache &&
travis_retry curl -fo /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
chmod +x /usr/local/bin/stamp
- env: >
RUST_CHECK_TARGET=check
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
SRC=.
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.8
MACOSX_STD_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode8.2
install: *osx_install_sccache
# OSX builders producing releases. These do not run the full test suite and
# just produce a bunch of artifacts.
#
# Note that these are running in the `xcode7` image instead of the
# `xcode8.2` image as above. That's because we want to build releases for
# OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7.
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-extended --enable-profiler"
SRC=.
DEPLOY=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
install:
- travis_retry brew update
- travis_retry brew install xz
- *osx_install_sccache
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended --enable-sanitizers --enable-profiler"
SRC=.
DEPLOY=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
install:
- travis_retry brew update
- travis_retry brew install xz
- *osx_install_sccache
# "alternate" deployments, these are "nightlies" but don't have assertions
# turned on, they're deployed to a different location primarily for projects
# which are stuck on nightly and don't want llvm assertions in the artifacts
# that they use.
- env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1
- env: >
RUST_CHECK_TARGET=dist
RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler"
SRC=.
DEPLOY_ALT=1
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
SCCACHE_ERROR_LOG=/tmp/sccache.log
MACOSX_DEPLOYMENT_TARGET=10.7
os: osx
osx_image: xcode7
install:
- travis_retry brew update
- travis_retry brew install xz
- *osx_install_sccache
env: env:
global: global:
- SCCACHE_BUCKET=rust-lang-ci-sccache - SCCACHE_BUCKET=rust-lang-ci-sccache
@ -142,41 +129,64 @@ env:
# AWS_SECRET_ACCESS_KEY=... # AWS_SECRET_ACCESS_KEY=...
- secure: "Pixhh0hXDqGCdOyLtGFjli3J2AtDWIpyb2btIrLe956nCBDRutRoMm6rv5DI9sFZN07Mms7VzNNvhc9wCW1y63JAm414d2Co7Ob8kWMZlz9l9t7ACHuktUiis8yr+S4Quq1Vqd6pqi7pf2J++UxC8R/uLeqVrubzr6+X7AbmEFE=" - secure: "Pixhh0hXDqGCdOyLtGFjli3J2AtDWIpyb2btIrLe956nCBDRutRoMm6rv5DI9sFZN07Mms7VzNNvhc9wCW1y63JAm414d2Co7Ob8kWMZlz9l9t7ACHuktUiis8yr+S4Quq1Vqd6pqi7pf2J++UxC8R/uLeqVrubzr6+X7AbmEFE="
# Note that this is overridden on OSX builders before_install:
install: > # If we are building a pull request, do the build if $ALLOW_PR == 1
travis_retry curl -fo $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && # Otherwise, do the build if we are on the auto branch, or the try branch and $ALLOW_TRY == 1
chmod +x $HOME/stamp && - >
export PATH=$PATH:$HOME if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
if [[ "$ALLOW_PR" == "1" ]]; then
export SKIP_BUILD=false;
else
export SKIP_BUILD=true;
fi;
elif [[ "$TRAVIS_BRANCH" == "auto" || ( "$ALLOW_TRY" == "1" && "$TRAVIS_BRANCH" == "try" ) ]]; then
export SKIP_BUILD=false;
else
export SKIP_BUILD=true;
fi
- >
if [[ "$SKIP_BUILD" == false ]]; then
zcat $HOME/docker/rust-ci.tar.gz | docker load || true
fi
- mkdir -p $HOME/rustsrc
install:
- >
if [[ "$SKIP_BUILD" == true ]]; then
echo echo skipping, not a full build > $HOME/stamp &&
chmod +x $HOME/stamp &&
export PATH=$PATH:$HOME;
else
case "$TRAVIS_OS_NAME" in
linux)
travis_retry curl -fo $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl &&
chmod +x $HOME/stamp &&
export PATH=$PATH:$HOME
;;
osx)
if [[ "$RUST_CHECK_TARGET" == dist ]]; then
travis_retry brew update &&
travis_retry brew install xz;
fi &&
travis_retry curl -fo /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin &&
chmod +x /usr/local/bin/sccache &&
travis_retry curl -fo /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
chmod +x /usr/local/bin/stamp
;;
esac
fi
before_script: before_script:
- > - >
echo "#### Disk usage before running script:"; echo "#### Disk usage before running script:";
df -h; df -h;
du . | sort -nr | head -n100 du . | sort -nr | head -n100
# If we are building a pull request, do the build if $ALLOW_PR == 1
# Otherwise, do the build if we are on the auto branch, or the try branch and $ALLOW_TRY == 1
- > - >
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
if [[ "$ALLOW_PR" == "1" ]]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then
SKIP_BUILD=false; export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
else
SKIP_BUILD=true;
fi
elif [[ "$TRAVIS_BRANCH" == "auto" || ( "$ALLOW_TRY" == "1" && "$TRAVIS_BRANCH" == "try" ) ]]; then
SKIP_BUILD=false;
else else
SKIP_BUILD=true; export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
fi
if [[ "$SKIP_BUILD" == true ]]; then
export RUN_SCRIPT="echo 'skipping, not a full build'";
else
RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
else
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
fi
fi fi
# Log time information from this machine and an external machine for insight into possible # Log time information from this machine and an external machine for insight into possible
@ -223,9 +233,6 @@ before_cache:
grep -v missing | grep -v missing |
xargs docker save | xargs docker save |
gzip > $HOME/docker/rust-ci.tar.gz gzip > $HOME/docker/rust-ci.tar.gz
before_install:
- zcat $HOME/docker/rust-ci.tar.gz | docker load || true
- mkdir -p $HOME/rustsrc
notifications: notifications:
email: false email: false

View file

@ -289,7 +289,7 @@ been approved. The PR then enters the [merge queue][merge-queue], where @bors
will run all the tests on every platform we support. If it all works out, will run all the tests on every platform we support. If it all works out,
@bors will merge your code into `master` and close the pull request. @bors will merge your code into `master` and close the pull request.
[merge-queue]: https://buildbot.rust-lang.org/homu/queue/rust [merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust
Speaking of tests, Rust has a comprehensive test suite. More information about Speaking of tests, Rust has a comprehensive test suite. More information about
it can be found it can be found

View file

@ -15,7 +15,7 @@ URL=https://dl.google.com/android/repository
download_ndk() { download_ndk() {
mkdir -p /android/ndk mkdir -p /android/ndk
cd /android/ndk cd /android/ndk
curl -sO $URL/$1 curl -fO $URL/$1
unzip -q $1 unzip -q $1
rm $1 rm $1
mv android-ndk-* ndk mv android-ndk-* ndk

View file

@ -15,7 +15,7 @@ URL=https://dl.google.com/android/repository
download_sdk() { download_sdk() {
mkdir -p /android/sdk mkdir -p /android/sdk
cd /android/sdk cd /android/sdk
curl -sO $URL/$1 curl -fO $URL/$1
unzip -q $1 unzip -q $1
rm -rf $1 rm -rf $1
} }

View file

@ -11,7 +11,7 @@
set -ex set -ex
url="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2" url="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2"
curl -s $url | tar xjf - curl -f $url | tar xjf -
cd crosstool-ng cd crosstool-ng
./configure --prefix=/usr/local ./configure --prefix=/usr/local
make -j$(nproc) make -j$(nproc)

View file

@ -10,6 +10,6 @@
set -ex set -ex
curl -sOL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb curl -fOL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb
dpkg -i dumb-init_*.deb dpkg -i dumb-init_*.deb
rm dumb-init_*.deb rm dumb-init_*.deb

View file

@ -28,7 +28,7 @@ exit 1
} }
# Download last known good emscripten from WebAssembly waterfall # Download last known good emscripten from WebAssembly waterfall
BUILD=$(curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \ BUILD=$(curl -fL https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \
jq '.build | tonumber') jq '.build | tonumber')
curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \ curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \
hide_output tar xvkj hide_output tar xvkj

View file

@ -28,7 +28,7 @@ exit 1
} }
cd / cd /
curl -sL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ curl -fL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
tar -xz tar -xz
cd /emsdk-portable cd /emsdk-portable

View file

@ -10,7 +10,7 @@
set -ex set -ex
curl -s https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - curl -f https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf -
cd make-3.81 cd make-3.81
./configure --prefix=/usr ./configure --prefix=/usr
make make

View file

@ -10,7 +10,7 @@
set -ex set -ex
curl -so /usr/local/bin/sccache \ curl -fo /usr/local/bin/sccache \
https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl
chmod +x /usr/local/bin/sccache chmod +x /usr/local/bin/sccache

View file

@ -973,7 +973,7 @@ impl<T> From<T> for Rc<T> {
/// A `Weak` pointer is useful for keeping a temporary reference to the value /// A `Weak` pointer is useful for keeping a temporary reference to the value
/// within [`Rc`] without extending its lifetime. It is also used to prevent /// within [`Rc`] without extending its lifetime. It is also used to prevent
/// circular references between [`Rc`] pointers, since mutual owning references /// circular references between [`Rc`] pointers, since mutual owning references
/// would never allow either [`Arc`] to be dropped. For example, a tree could /// would never allow either [`Rc`] to be dropped. For example, a tree could
/// have strong [`Rc`] pointers from parent nodes to children, and `Weak` /// have strong [`Rc`] pointers from parent nodes to children, and `Weak`
/// pointers from children back to their parents. /// pointers from children back to their parents.
/// ///

View file

@ -126,7 +126,7 @@ pub trait Default: Sized {
} }
macro_rules! default_impl { macro_rules! default_impl {
($t:ty, $v:expr, $doc:expr) => { ($t:ty, $v:expr, $doc:tt) => {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Default for $t { impl Default for $t {
#[inline] #[inline]

View file

@ -81,6 +81,22 @@ pub type Result = result::Result<(), Error>;
/// This type does not support transmission of an error other than that an error /// This type does not support transmission of an error other than that an error
/// occurred. Any extra information must be arranged to be transmitted through /// occurred. Any extra information must be arranged to be transmitted through
/// some other means. /// some other means.
///
/// An important thing to remember is that the type `fmt::Error` should not be
/// confused with `std::io::Error` or `std::error::Error`, which you may also
/// have in scope.
///
/// # Examples
///
/// ```rust
/// use std::fmt::{self, write};
///
/// let mut output = String::new();
/// match write(&mut output, format_args!("Hello {}!", "world")) {
/// Err(fmt::Error) => panic!("An error occurred"),
/// _ => (),
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error; pub struct Error;

View file

@ -1094,7 +1094,7 @@ impl f32 {
/// assert_eq!((12.5f32).to_bits(), 0x41480000); /// assert_eq!((12.5f32).to_bits(), 0x41480000);
/// ///
/// ``` /// ```
#[stable(feature = "float_bits_conv", since = "1.21.0")] #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline] #[inline]
pub fn to_bits(self) -> u32 { pub fn to_bits(self) -> u32 {
unsafe { ::mem::transmute(self) } unsafe { ::mem::transmute(self) }
@ -1125,7 +1125,7 @@ impl f32 {
/// let snan = 0x7F800001; /// let snan = 0x7F800001;
/// assert_ne!(f32::from_bits(snan).to_bits(), snan); /// assert_ne!(f32::from_bits(snan).to_bits(), snan);
/// ``` /// ```
#[stable(feature = "float_bits_conv", since = "1.21.0")] #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline] #[inline]
pub fn from_bits(mut v: u32) -> Self { pub fn from_bits(mut v: u32) -> Self {
const EXP_MASK: u32 = 0x7F800000; const EXP_MASK: u32 = 0x7F800000;

View file

@ -1009,7 +1009,7 @@ impl f64 {
/// assert_eq!((12.5f64).to_bits(), 0x4029000000000000); /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
/// ///
/// ``` /// ```
#[stable(feature = "float_bits_conv", since = "1.21.0")] #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline] #[inline]
pub fn to_bits(self) -> u64 { pub fn to_bits(self) -> u64 {
unsafe { ::mem::transmute(self) } unsafe { ::mem::transmute(self) }
@ -1040,7 +1040,7 @@ impl f64 {
/// let snan = 0x7FF0000000000001; /// let snan = 0x7FF0000000000001;
/// assert_ne!(f64::from_bits(snan).to_bits(), snan); /// assert_ne!(f64::from_bits(snan).to_bits(), snan);
/// ``` /// ```
#[stable(feature = "float_bits_conv", since = "1.21.0")] #[stable(feature = "float_bits_conv", since = "1.20.0")]
#[inline] #[inline]
pub fn from_bits(mut v: u64) -> Self { pub fn from_bits(mut v: u64) -> Self {
const EXP_MASK: u64 = 0x7FF0000000000000; const EXP_MASK: u64 = 0x7FF0000000000000;

View file

@ -2346,17 +2346,17 @@ mod tests {
#[test] #[test]
fn recursive_mkdir_slash() { fn recursive_mkdir_slash() {
check!(fs::create_dir_all(&Path::new("/"))); check!(fs::create_dir_all(Path::new("/")));
} }
#[test] #[test]
fn recursive_mkdir_dot() { fn recursive_mkdir_dot() {
check!(fs::create_dir_all(&Path::new("."))); check!(fs::create_dir_all(Path::new(".")));
} }
#[test] #[test]
fn recursive_mkdir_empty() { fn recursive_mkdir_empty() {
check!(fs::create_dir_all(&Path::new(""))); check!(fs::create_dir_all(Path::new("")));
} }
#[test] #[test]

View file

@ -29,7 +29,7 @@ impl TcpStream {
let mut options = OpenOptions::new(); let mut options = OpenOptions::new();
options.read(true); options.read(true);
options.write(true); options.write(true);
Ok(TcpStream(File::open(&Path::new(path.as_str()), &options)?)) Ok(TcpStream(File::open(Path::new(path.as_str()), &options)?))
} }
pub fn connect_timeout(_addr: &SocketAddr, _timeout: Duration) -> Result<TcpStream> { pub fn connect_timeout(_addr: &SocketAddr, _timeout: Duration) -> Result<TcpStream> {
@ -177,7 +177,7 @@ impl TcpListener {
let mut options = OpenOptions::new(); let mut options = OpenOptions::new();
options.read(true); options.read(true);
options.write(true); options.write(true);
Ok(TcpListener(File::open(&Path::new(path.as_str()), &options)?)) Ok(TcpListener(File::open(Path::new(path.as_str()), &options)?))
} }
pub fn accept(&self) -> Result<(TcpStream, SocketAddr)> { pub fn accept(&self) -> Result<(TcpStream, SocketAddr)> {

View file

@ -30,7 +30,7 @@ impl UdpSocket {
let mut options = OpenOptions::new(); let mut options = OpenOptions::new();
options.read(true); options.read(true);
options.write(true); options.write(true);
Ok(UdpSocket(File::open(&Path::new(path.as_str()), &options)?, UnsafeCell::new(None))) Ok(UdpSocket(File::open(Path::new(path.as_str()), &options)?, UnsafeCell::new(None)))
} }
fn get_conn(&self) -> &mut Option<SocketAddr> { fn get_conn(&self) -> &mut Option<SocketAddr> {

View file

@ -73,10 +73,10 @@ pub fn split_paths(unparsed: &OsStr) -> SplitPaths {
fn bytes_to_path(b: &[u8]) -> PathBuf { fn bytes_to_path(b: &[u8]) -> PathBuf {
PathBuf::from(<OsStr as OsStrExt>::from_bytes(b)) PathBuf::from(<OsStr as OsStrExt>::from_bytes(b))
} }
fn is_colon(b: &u8) -> bool { *b == b':' } fn is_semicolon(b: &u8) -> bool { *b == b';' }
let unparsed = unparsed.as_bytes(); let unparsed = unparsed.as_bytes();
SplitPaths { SplitPaths {
iter: unparsed.split(is_colon as fn(&u8) -> bool) iter: unparsed.split(is_semicolon as fn(&u8) -> bool)
.map(bytes_to_path as fn(&[u8]) -> PathBuf) .map(bytes_to_path as fn(&[u8]) -> PathBuf)
} }
} }
@ -94,7 +94,7 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
where I: Iterator<Item=T>, T: AsRef<OsStr> where I: Iterator<Item=T>, T: AsRef<OsStr>
{ {
let mut joined = Vec::new(); let mut joined = Vec::new();
let sep = b':'; let sep = b';';
for (i, path) in paths.enumerate() { for (i, path) in paths.enumerate() {
let path = path.as_ref().as_bytes(); let path = path.as_ref().as_bytes();

View file

@ -9,11 +9,12 @@
// except according to those terms. // except according to those terms.
use collections::hash_map::HashMap; use collections::hash_map::HashMap;
use env; use env::{self, split_paths};
use ffi::OsStr; use ffi::OsStr;
use os::unix::ffi::OsStrExt;
use fmt; use fmt;
use io::{self, Error, ErrorKind}; use io::{self, Error, ErrorKind};
use path::Path; use path::{Path, PathBuf};
use sys::fd::FileDesc; use sys::fd::FileDesc;
use sys::fs::{File, OpenOptions}; use sys::fs::{File, OpenOptions};
use sys::pipe::{self, AnonPipe}; use sys::pipe::{self, AnonPipe};
@ -313,23 +314,29 @@ impl Command {
} }
let program = if self.program.contains(':') || self.program.contains('/') { let program = if self.program.contains(':') || self.program.contains('/') {
self.program.to_owned() Some(PathBuf::from(&self.program))
} else { } else if let Ok(path_env) = ::env::var("PATH") {
let mut path_env = ::env::var("PATH").unwrap_or(".".to_string()); let mut program = None;
for mut path in split_paths(&path_env) {
if ! path_env.ends_with('/') { path.push(&self.program);
path_env.push('/'); if path.exists() {
program = Some(path);
break;
}
} }
program
path_env.push_str(&self.program); } else {
None
path_env
}; };
if let Err(err) = syscall::execve(&program, &args) { if let Some(program) = program {
io::Error::from_raw_os_error(err.errno as i32) if let Err(err) = syscall::execve(program.as_os_str().as_bytes(), &args) {
io::Error::from_raw_os_error(err.errno as i32)
} else {
panic!("return from exec without err");
}
} else { } else {
panic!("return from exec without err"); io::Error::new(io::ErrorKind::NotFound, "")
} }
} }
@ -393,7 +400,7 @@ impl Stdio {
let mut opts = OpenOptions::new(); let mut opts = OpenOptions::new();
opts.read(readable); opts.read(readable);
opts.write(!readable); opts.write(!readable);
let fd = File::open(&Path::new("null:"), &opts)?; let fd = File::open(Path::new("null:"), &opts)?;
Ok((ChildStdio::Owned(fd.into_fd()), None)) Ok((ChildStdio::Owned(fd.into_fd()), None))
} }
} }

View file

@ -77,9 +77,9 @@ pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> {
} }
/// Replace the current process with a new executable /// Replace the current process with a new executable
pub fn execve(path: &str, args: &[[usize; 2]]) -> Result<usize> { pub fn execve<T: AsRef<[u8]>>(path: T, args: &[[usize; 2]]) -> Result<usize> {
unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(), unsafe { syscall4(SYS_EXECVE, path.as_ref().as_ptr() as usize,
args.as_ptr() as usize, args.len()) } path.as_ref().len(), args.as_ptr() as usize, args.len()) }
} }
/// Exit the current process /// Exit the current process

View file

@ -1,4 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. // http://rust-lang.org/COPYRIGHT.
// //
@ -18,9 +18,10 @@ const MILLIS_PER_SEC: u64 = 1_000;
/// A `Duration` type to represent a span of time, typically used for system /// A `Duration` type to represent a span of time, typically used for system
/// timeouts. /// timeouts.
/// ///
/// Each `Duration` is composed of a number of seconds and nanosecond precision. /// Each `Duration` is composed of a whole number of seconds and a fractional part
/// APIs binding a system timeout will typically round up the nanosecond /// represented in nanoseconds. If the underlying system does not support
/// precision if the underlying system does not support that level of precision. /// nanosecond-level precision, APIs binding a system timeout will typically round up
/// the number of nanoseconds.
/// ///
/// `Duration`s implement many common traits, including [`Add`], [`Sub`], and other /// `Duration`s implement many common traits, including [`Add`], [`Sub`], and other
/// [`ops`] traits. /// [`ops`] traits.
@ -50,11 +51,11 @@ pub struct Duration {
} }
impl Duration { impl Duration {
/// Creates a new `Duration` from the specified number of seconds and /// Creates a new `Duration` from the specified number of whole seconds and
/// additional nanosecond precision. /// additional nanoseconds.
/// ///
/// If the nanoseconds is greater than 1 billion (the number of nanoseconds /// If the number of nanoseconds is greater than 1 billion (the number of
/// in a second), then it will carry over into the seconds provided. /// nanoseconds in a second), then it will carry over into the seconds provided.
/// ///
/// # Panics /// # Panics
/// ///
@ -77,7 +78,7 @@ impl Duration {
Duration { secs: secs, nanos: nanos } Duration { secs: secs, nanos: nanos }
} }
/// Creates a new `Duration` from the specified number of seconds. /// Creates a new `Duration` from the specified number of whole seconds.
/// ///
/// # Examples /// # Examples
/// ///
@ -115,10 +116,10 @@ impl Duration {
Duration { secs: secs, nanos: nanos } Duration { secs: secs, nanos: nanos }
} }
/// Returns the number of whole seconds represented by this `Duration`. /// Returns the number of _whole_ seconds contained by this `Duration`.
/// ///
/// The extra precision represented by this duration is ignored (i.e. extra /// The returned value does not include the fractional (nanosecond) part of the
/// nanoseconds are not represented in the returned value). /// duration, which can be obtained using [`subsec_nanos`].
/// ///
/// # Examples /// # Examples
/// ///
@ -147,7 +148,7 @@ impl Duration {
#[inline] #[inline]
pub fn as_secs(&self) -> u64 { self.secs } pub fn as_secs(&self) -> u64 { self.secs }
/// Returns the nanosecond precision represented by this `Duration`. /// Returns the fractional part of this `Duration`, in nanoseconds.
/// ///
/// This method does **not** return the length of the duration when /// This method does **not** return the length of the duration when
/// represented by nanoseconds. The returned number always represents a /// represented by nanoseconds. The returned number always represents a
@ -159,7 +160,8 @@ impl Duration {
/// use std::time::Duration; /// use std::time::Duration;
/// ///
/// let duration = Duration::from_millis(5010); /// let duration = Duration::from_millis(5010);
/// assert_eq!(duration.subsec_nanos(), 10000000); /// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_nanos(), 10_000_000);
/// ``` /// ```
#[stable(feature = "duration", since = "1.3.0")] #[stable(feature = "duration", since = "1.3.0")]
#[inline] #[inline]

View file

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
// ignore-arm // ignore-arm
// ignore-powerpc
// ignore-wasm // ignore-wasm
// ignore-emscripten // ignore-emscripten
// ignore-windows // ignore-windows