diff --git a/.travis.yml b/.travis.yml index 827f5fd159ae3..ca28aabc41fde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,7 +126,8 @@ matrix: env: global: - - SCCACHE_BUCKET=rust-lang-ci-sccache + - SCCACHE_BUCKET=rust-lang-ci-sccache2 + - SCCACHE_REGION=us-west-1 - AWS_ACCESS_KEY_ID=AKIAJAMV3QAMMA6AXHFQ # AWS_SECRET_ACCESS_KEY=... - secure: "j96XxTVOSUf4s4r4htIxn/fvIa5DWbMgLqWl7r8z2QfgUwscmkMXAwXuFNc7s7bGTpV/+CgDiMFFM6BAFLGKutytIF6oA02s9b+usQYnM0th7YQ2AIgm9GtMTJCJp4AoyfFmh8F2faUICBZlfVLUJ34udHEe35vOklix+0k4WDo=" @@ -161,7 +162,7 @@ install: 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 && + travis_retry curl -fo $HOME/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && chmod +x $HOME/stamp && export PATH=$PATH:$HOME ;; @@ -170,9 +171,9 @@ install: 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 && + travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/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 && + travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && chmod +x /usr/local/bin/stamp ;; esac @@ -256,12 +257,12 @@ before_deploy: deploy: - provider: s3 - bucket: rust-lang-ci + bucket: rust-lang-ci2 skip_cleanup: true local_dir: deploy upload_dir: rustc-builds acl: public_read - region: us-east-1 + region: us-west-1 access_key_id: AKIAJVBODR3IA4O72THQ secret_access_key: secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0=" @@ -270,12 +271,12 @@ deploy: condition: $DEPLOY = 1 - provider: s3 - bucket: rust-lang-ci + bucket: rust-lang-ci2 skip_cleanup: true local_dir: deploy upload_dir: rustc-builds-try acl: public_read - region: us-east-1 + region: us-west-1 access_key_id: AKIAJVBODR3IA4O72THQ secret_access_key: secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0=" @@ -286,12 +287,12 @@ deploy: # this is the same as the above deployment provider except that it uploads to # a slightly different directory and has a different trigger - provider: s3 - bucket: rust-lang-ci + bucket: rust-lang-ci2 skip_cleanup: true local_dir: deploy upload_dir: rustc-builds-alt acl: public_read - region: us-east-1 + region: us-west-1 access_key_id: AKIAJVBODR3IA4O72THQ secret_access_key: secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0=" diff --git a/appveyor.yml b/appveyor.yml index 62b62ae7c42e9..599d1b40ceb1e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,6 @@ environment: - SCCACHE_BUCKET: rust-lang-ci-sccache + SCCACHE_BUCKET: rust-lang-ci-sccache2 + SCCACHE_REGION: us-west-1 AWS_ACCESS_KEY_ID: AKIAJAMV3QAMMA6AXHFQ AWS_SECRET_ACCESS_KEY: secure: 7Y+JiquYedOAgnUU26uL0DPzrxmTtR+qIwG6rNKSuWDffqU3vVZxbGXim9QpTO80 @@ -40,13 +41,13 @@ environment: - MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: python x.py test - MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror + MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 - MSYS_BITS: 64 SCRIPT: python x.py test RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror + MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 @@ -67,14 +68,14 @@ environment: - MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-extended SCRIPT: python x.py dist - MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror + MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 DEPLOY: 1 - MSYS_BITS: 64 SCRIPT: python x.py dist RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-extended - MINGW_URL: https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror + MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 DEPLOY: 1 @@ -132,25 +133,25 @@ install: - set PATH=C:\Python27;%PATH% # Download and install sccache - - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-pc-windows-msvc + - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-12-sccache-x86_64-pc-windows-msvc - mv 2017-05-12-sccache-x86_64-pc-windows-msvc sccache.exe - set PATH=%PATH%;%CD% # Download and install ninja # # Note that this is originally from the github releases patch of Ninja - - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-15-ninja-win.zip + - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-15-ninja-win.zip - 7z x 2017-03-15-ninja-win.zip - set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja # - set PATH=%PATH%;%CD% -- this already happens above for sccache # Install InnoSetup to get `iscc` used to produce installers - - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-08-22-is.exe + - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-08-22-is.exe - 2017-08-22-is.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- - set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% # Help debug some handle issues on AppVeyor - - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-15-Handle.zip + - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-15-Handle.zip - mkdir handle - 7z x -ohandle 2017-05-15-Handle.zip - set PATH=%PATH%;%CD%\handle @@ -188,9 +189,9 @@ deploy: access_key_id: AKIAJVBODR3IA4O72THQ secret_access_key: secure: tQWIE+DJHjXaV4np/3YeETkEmXngtIuIgAO/LYKQaUshGLgN8cBCFGG3cHx5lKLt - bucket: rust-lang-ci + bucket: rust-lang-ci2 set_public: true - region: us-east-1 + region: us-west-1 artifact: /.*/ folder: rustc-builds on: @@ -205,9 +206,9 @@ deploy: access_key_id: AKIAJVBODR3IA4O72THQ secret_access_key: secure: tQWIE+DJHjXaV4np/3YeETkEmXngtIuIgAO/LYKQaUshGLgN8cBCFGG3cHx5lKLt - bucket: rust-lang-ci + bucket: rust-lang-ci2 set_public: true - region: us-east-1 + region: us-west-1 artifact: /.*/ folder: rustc-builds-alt on: diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 0a307e72bf61d..8429b64513dcf 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -349,7 +349,7 @@ impl Step for Openssl { if !tarball.exists() { let tmp = tarball.with_extension("tmp"); // originally from https://www.openssl.org/source/... - let url = format!("https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/{}", + let url = format!("https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/{}", name); let mut ok = false; for _ in 0..3 { diff --git a/src/ci/docker/cross/install-mips-musl.sh b/src/ci/docker/cross/install-mips-musl.sh index 416bb75155e74..eeb4aacbbb74c 100755 --- a/src/ci/docker/cross/install-mips-musl.sh +++ b/src/ci/docker/cross/install-mips-musl.sh @@ -15,7 +15,7 @@ mkdir /usr/local/mips-linux-musl # originally from # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/ # OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2 -URL="https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror" +URL="https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror" FILE="OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2" curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mips-linux-musl --strip-components=2 diff --git a/src/ci/docker/cross/install-mipsel-musl.sh b/src/ci/docker/cross/install-mipsel-musl.sh index 9744b242fb919..74b6a10e77a67 100755 --- a/src/ci/docker/cross/install-mipsel-musl.sh +++ b/src/ci/docker/cross/install-mipsel-musl.sh @@ -15,7 +15,7 @@ mkdir /usr/local/mipsel-linux-musl # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/malta/generic/ # OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -URL="https://s3.amazonaws.com/rust-lang-ci/libc" +URL="https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc" FILE="OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2" curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2 diff --git a/src/ci/docker/dist-i686-linux/build-openssl.sh b/src/ci/docker/dist-i686-linux/build-openssl.sh index 27cd064f901a0..34da0ed631093 100755 --- a/src/ci/docker/dist-i686-linux/build-openssl.sh +++ b/src/ci/docker/dist-i686-linux/build-openssl.sh @@ -13,7 +13,7 @@ set -ex source shared.sh VERSION=1.0.2k -URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/openssl-$VERSION.tar.gz +URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/openssl-$VERSION.tar.gz curl $URL | tar xzf - diff --git a/src/ci/docker/dist-x86_64-linux/build-openssl.sh b/src/ci/docker/dist-x86_64-linux/build-openssl.sh index 27cd064f901a0..34da0ed631093 100755 --- a/src/ci/docker/dist-x86_64-linux/build-openssl.sh +++ b/src/ci/docker/dist-x86_64-linux/build-openssl.sh @@ -13,7 +13,7 @@ set -ex source shared.sh VERSION=1.0.2k -URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/openssl-$VERSION.tar.gz +URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/openssl-$VERSION.tar.gz curl $URL | tar xzf - diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index ea335a249736c..54100b49cb9f5 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -35,7 +35,7 @@ cd netbsd mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot -URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror +URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz curl $URL/2017-03-17-netbsd-src.tgz | tar xzf - diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 5eba81ff60a22..7087033e117a2 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -57,9 +57,10 @@ mkdir -p $objdir/tmp args= if [ "$SCCACHE_BUCKET" != "" ]; then - args="$args --env SCCACHE_BUCKET=$SCCACHE_BUCKET" - args="$args --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" - args="$args --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" + args="$args --env SCCACHE_BUCKET" + args="$args --env SCCACHE_REGION" + args="$args --env AWS_ACCESS_KEY_ID" + args="$args --env AWS_SECRET_ACCESS_KEY" args="$args --env SCCACHE_ERROR_LOG=/tmp/sccache/sccache.log" args="$args --volume $objdir/tmp:/tmp/sccache" else @@ -82,10 +83,10 @@ exec docker \ --env SRC=/checkout \ $args \ --env CARGO_HOME=/cargo \ - --env DEPLOY=$DEPLOY \ - --env DEPLOY_ALT=$DEPLOY_ALT \ + --env DEPLOY \ + --env DEPLOY_ALT \ --env LOCAL_USER_ID=`id -u` \ - --env TRAVIS=${TRAVIS-false} \ + --env TRAVIS \ --env TRAVIS_BRANCH \ --volume "$HOME/.cargo:/cargo" \ --volume "$HOME/rustsrc:$HOME/rustsrc" \ diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index 98b0ed712c02a..ce2d45563f7b5 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -8,9 +8,11 @@ # option. This file may not be copied, modified, or distributed # except according to those terms. +# ignore-tidy-linelength + set -ex 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-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl chmod +x /usr/local/bin/sccache diff --git a/src/doc/unstable-book/src/library-features/compiler-fences.md b/src/doc/unstable-book/src/library-features/compiler-fences.md deleted file mode 100644 index b1e36ab13d5ae..0000000000000 --- a/src/doc/unstable-book/src/library-features/compiler-fences.md +++ /dev/null @@ -1,106 +0,0 @@ -# `compiler_fences` - -The tracking issue for this feature is: [#41091] - -[#41091]: https://github.com/rust-lang/rust/issues/41091 - ------------------------- - -The `compiler_fences` feature exposes the `compiler_fence` function -in `std::sync::atomic`. This function is conceptually similar to C++'s -`atomic_signal_fence`, which can currently only be accessed in nightly -Rust using the `atomic_singlethreadfence_*` instrinsic functions in -`core`, or through the mostly equivalent literal assembly: - -```rust -#![feature(asm)] -unsafe { asm!("" ::: "memory" : "volatile") }; -``` - -A `compiler_fence` restricts the kinds of memory re-ordering the -compiler is allowed to do. Specifically, depending on the given ordering -semantics, the compiler may be disallowed from moving reads or writes -from before or after the call to the other side of the call to -`compiler_fence`. Note that it does **not** prevent the *hardware* -from doing such re-ordering. This is not a problem in a single-threaded, -execution context, but when other threads may modify memory at the same -time, stronger synchronization primitives are required. - -## Examples - -`compiler_fence` is generally only useful for preventing a thread from -racing *with itself*. That is, if a given thread is executing one piece -of code, and is then interrupted, and starts executing code elsewhere -(while still in the same thread, and conceptually still on the same -core). In traditional programs, this can only occur when a signal -handler is registered. In more low-level code, such situations can also -arise when handling interrupts, when implementing green threads with -pre-emption, etc. - -To give a straightforward example of when a `compiler_fence` is -necessary, consider the following example: - -```rust -# use std::sync::atomic::{AtomicBool, AtomicUsize}; -# use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT}; -# use std::sync::atomic::Ordering; -static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; -static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; - -fn main() { - IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); - IS_READY.store(true, Ordering::Relaxed); -} - -fn signal_handler() { - if IS_READY.load(Ordering::Relaxed) { - assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); - } -} -``` - -The way it is currently written, the `assert_eq!` is *not* guaranteed to -succeed, despite everything happening in a single thread. To see why, -remember that the compiler is free to swap the stores to -`IMPORTANT_VARIABLE` and `IS_READ` since they are both -`Ordering::Relaxed`. If it does, and the signal handler is invoked right -after `IS_READY` is updated, then the signal handler will see -`IS_READY=1`, but `IMPORTANT_VARIABLE=0`. - -Using a `compiler_fence`, we can remedy this situation: - -```rust -#![feature(compiler_fences)] -# use std::sync::atomic::{AtomicBool, AtomicUsize}; -# use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT}; -# use std::sync::atomic::Ordering; -use std::sync::atomic::compiler_fence; - -static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; -static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; - -fn main() { - IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); - // prevent earlier writes from being moved beyond this point - compiler_fence(Ordering::Release); - IS_READY.store(true, Ordering::Relaxed); -} - -fn signal_handler() { - if IS_READY.load(Ordering::Relaxed) { - assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); - } -} -``` - -A deeper discussion of compiler barriers with various re-ordering -semantics (such as `Ordering::SeqCst`) is beyond the scope of this text. -Curious readers are encouraged to read the Linux kernel's discussion of -[memory barriers][1], the C++ references on [`std::memory_order`][2] and -[`atomic_signal_fence`][3], and [this StackOverflow answer][4] for -further details. - -[1]: https://www.kernel.org/doc/Documentation/memory-barriers.txt -[2]: http://en.cppreference.com/w/cpp/atomic/memory_order -[3]: http://www.cplusplus.com/reference/atomic/atomic_signal_fence/ -[4]: http://stackoverflow.com/a/18454971/472927 diff --git a/src/doc/unstable-book/src/library-features/iterator-for-each.md b/src/doc/unstable-book/src/library-features/iterator-for-each.md deleted file mode 100644 index ebeb5f6a1de51..0000000000000 --- a/src/doc/unstable-book/src/library-features/iterator-for-each.md +++ /dev/null @@ -1,17 +0,0 @@ -# `iterator_for_each` - -The tracking issue for this feature is: [#42986] - -[#42986]: https://github.com/rust-lang/rust/issues/42986 - ------------------------- - -To call a closure on each element of an iterator, you can use `for_each`: - -```rust -#![feature(iterator_for_each)] - -fn main() { - (0..10).for_each(|i| println!("{}", i)); -} -``` diff --git a/src/doc/unstable-book/src/library-features/splice.md b/src/doc/unstable-book/src/library-features/splice.md index ca7f78a8f79e5..3d33f02076802 100644 --- a/src/doc/unstable-book/src/library-features/splice.md +++ b/src/doc/unstable-book/src/library-features/splice.md @@ -1,14 +1,13 @@ # `splice` -The tracking issue for this feature is: [#32310] +The tracking issue for this feature is: [#44643] -[#32310]: https://github.com/rust-lang/rust/issues/32310 +[#44643]: https://github.com/rust-lang/rust/issues/44643 ------------------------ -The `splice()` method on `Vec` and `String` allows you to replace a range -of values in a vector or string with another range of values, and returns -the replaced values. +The `splice()` method on `String` allows you to replace a range +of values in a string with another range of values. A simple example: @@ -21,4 +20,4 @@ let beta_offset = s.find('β').unwrap_or(s.len()); let t: String = s.splice(..beta_offset, "Α is capital alpha; ").collect(); assert_eq!(t, "α is alpha, "); assert_eq!(s, "Α is capital alpha; β is beta"); -``` \ No newline at end of file +``` diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index b1919c7c968c9..db8b4f1f23178 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1420,7 +1420,7 @@ impl String { /// assert_eq!(t, "α is alpha, "); /// assert_eq!(s, "Α is capital alpha; β is beta"); /// ``` - #[unstable(feature = "splice", reason = "recently added", issue = "32310")] + #[unstable(feature = "splice", reason = "recently added", issue = "44643")] pub fn splice<'a, 'b, R>(&'a mut self, range: R, replace_with: &'b str) -> Splice<'a, 'b> where R: RangeArgument { @@ -2250,7 +2250,7 @@ impl<'a> FusedIterator for Drain<'a> {} /// [`splice()`]: struct.String.html#method.splice /// [`String`]: struct.String.html #[derive(Debug)] -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] pub struct Splice<'a, 'b> { /// Will be used as &'a mut String in the destructor string: *mut String, @@ -2263,12 +2263,12 @@ pub struct Splice<'a, 'b> { replace_with: &'b str, } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] unsafe impl<'a, 'b> Sync for Splice<'a, 'b> {} -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] unsafe impl<'a, 'b> Send for Splice<'a, 'b> {} -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] impl<'a, 'b> Drop for Splice<'a, 'b> { fn drop(&mut self) { unsafe { @@ -2278,7 +2278,7 @@ impl<'a, 'b> Drop for Splice<'a, 'b> { } } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] impl<'a, 'b> Iterator for Splice<'a, 'b> { type Item = char; @@ -2292,7 +2292,7 @@ impl<'a, 'b> Iterator for Splice<'a, 'b> { } } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[unstable(feature = "splice", reason = "recently added", issue = "44643")] impl<'a, 'b> DoubleEndedIterator for Splice<'a, 'b> { #[inline] fn next_back(&mut self) -> Option { diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 8141851b8c9af..3bfd78e6c06d0 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1942,7 +1942,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(splice)] /// let mut v = vec![1, 2, 3]; /// let new = [7, 8]; /// let u: Vec<_> = v.splice(..2, new.iter().cloned()).collect(); @@ -1950,7 +1949,7 @@ impl Vec { /// assert_eq!(u, &[1, 2]); /// ``` #[inline] - #[unstable(feature = "splice", reason = "recently added", issue = "32310")] + #[stable(feature = "vec_splice", since = "1.21.0")] pub fn splice(&mut self, range: R, replace_with: I) -> Splice where R: RangeArgument, I: IntoIterator { @@ -2550,13 +2549,13 @@ impl<'a, T> InPlace for PlaceBack<'a, T> { /// [`splice()`]: struct.Vec.html#method.splice /// [`Vec`]: struct.Vec.html #[derive(Debug)] -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[stable(feature = "vec_splice", since = "1.21.0")] pub struct Splice<'a, I: Iterator + 'a> { drain: Drain<'a, I::Item>, replace_with: I, } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> Iterator for Splice<'a, I> { type Item = I::Item; @@ -2569,18 +2568,18 @@ impl<'a, I: Iterator> Iterator for Splice<'a, I> { } } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> DoubleEndedIterator for Splice<'a, I> { fn next_back(&mut self) -> Option { self.drain.next_back() } } -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> ExactSizeIterator for Splice<'a, I> {} -#[unstable(feature = "splice", reason = "recently added", issue = "32310")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> Drop for Splice<'a, I> { fn drop(&mut self) { // exhaust drain first diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 96fcc81e8e6ed..2be7b1bc2e17c 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -28,7 +28,6 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![feature(generic_param_attrs)] -#![feature(needs_drop)] #![cfg_attr(test, feature(test))] #![allow(deprecated)] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index ec6525485f7a1..e012cbd76ff91 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -453,12 +453,10 @@ pub trait Ord: Eq + PartialOrd { /// # Examples /// /// ``` - /// #![feature(ord_max_min)] - /// /// assert_eq!(2, 1.max(2)); /// assert_eq!(2, 2.max(2)); /// ``` - #[unstable(feature = "ord_max_min", issue = "25663")] + #[stable(feature = "ord_max_min", since = "1.21.0")] fn max(self, other: Self) -> Self where Self: Sized { if other >= self { other } else { self } @@ -471,12 +469,10 @@ pub trait Ord: Eq + PartialOrd { /// # Examples /// /// ``` - /// #![feature(ord_max_min)] - /// /// assert_eq!(1, 1.min(2)); /// assert_eq!(2, 2.min(2)); /// ``` - #[unstable(feature = "ord_max_min", issue = "25663")] + #[stable(feature = "ord_max_min", since = "1.21.0")] fn min(self, other: Self) -> Self where Self: Sized { if self <= other { self } else { other } diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 7c009114afefb..ceb2a3f1d56b5 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -498,8 +498,6 @@ pub trait Iterator { /// Basic usage: /// /// ``` - /// #![feature(iterator_for_each)] - /// /// use std::sync::mpsc::channel; /// /// let (tx, rx) = channel(); @@ -514,15 +512,13 @@ pub trait Iterator { /// might be preferable to keep a functional style with longer iterators: /// /// ``` - /// #![feature(iterator_for_each)] - /// /// (0..5).flat_map(|x| x * 100 .. x * 110) /// .enumerate() /// .filter(|&(i, x)| (i + x) % 3 == 0) /// .for_each(|(i, x)| println!("{}:{}", i, x)); /// ``` #[inline] - #[unstable(feature = "iterator_for_each", issue = "42986")] + #[stable(feature = "iterator_for_each", since = "1.21.0")] fn for_each(self, mut f: F) where Self: Sized, F: FnMut(Self::Item), { diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 5dc6a94e1833d..bd08bd1a8fc63 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -372,7 +372,6 @@ pub fn align_of_val(val: &T) -> usize { /// Here's an example of how a collection might make use of needs_drop: /// /// ``` -/// #![feature(needs_drop)] /// use std::{mem, ptr}; /// /// pub struct MyCollection { @@ -399,7 +398,7 @@ pub fn align_of_val(val: &T) -> usize { /// } /// ``` #[inline] -#[unstable(feature = "needs_drop", issue = "41890")] +#[stable(feature = "needs_drop", since = "1.21.0")] pub fn needs_drop() -> bool { unsafe { intrinsics::needs_drop::() } } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 510e01db0e965..450afbe3fbe8d 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -1666,10 +1666,14 @@ pub fn fence(order: Ordering) { /// A compiler memory fence. /// -/// `compiler_fence` does not emit any machine code, but prevents the compiler from re-ordering -/// memory operations across this point. Which reorderings are disallowed is dictated by the given -/// [`Ordering`]. Note that `compiler_fence` does *not* introduce inter-thread memory -/// synchronization; for that, a [`fence`] is needed. +/// `compiler_fence` does not emit any machine code, but restricts the kinds +/// of memory re-ordering the compiler is allowed to do. Specifically, depending on +/// the given [`Ordering`] semantics, the compiler may be disallowed from moving reads +/// or writes from before or after the call to the other side of the call to +/// `compiler_fence`. Note that it does **not** prevent the *hardware* +/// from doing such re-ordering. This is not a problem in a single-threaded, +/// execution context, but when other threads may modify memory at the same +/// time, stronger synchronization primitives such as [`fence`] are required. /// /// The re-ordering prevented by the different ordering semantics are: /// @@ -1678,10 +1682,54 @@ pub fn fence(order: Ordering) { /// - with [`Acquire`], subsequent reads and writes cannot be moved ahead of preceding reads. /// - with [`AcqRel`], both of the above rules are enforced. /// +/// `compiler_fence` is generally only useful for preventing a thread from +/// racing *with itself*. That is, if a given thread is executing one piece +/// of code, and is then interrupted, and starts executing code elsewhere +/// (while still in the same thread, and conceptually still on the same +/// core). In traditional programs, this can only occur when a signal +/// handler is registered. In more low-level code, such situations can also +/// arise when handling interrupts, when implementing green threads with +/// pre-emption, etc. Curious readers are encouraged to read the Linux kernel's +/// discussion of [memory barriers]. +/// /// # Panics /// /// Panics if `order` is [`Relaxed`]. /// +/// # Examples +/// +/// Without `compiler_fence`, the `assert_eq!` in following code +/// is *not* guaranteed to succeed, despite everything happening in a single thread. +/// To see why, remember that the compiler is free to swap the stores to +/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both +/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right +/// after `IS_READY` is updated, then the signal handler will see +/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`. +/// Using a `compiler_fence` remedies this situation. +/// +/// ``` +/// use std::sync::atomic::{AtomicBool, AtomicUsize}; +/// use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT}; +/// use std::sync::atomic::Ordering; +/// use std::sync::atomic::compiler_fence; +/// +/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; +/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; +/// +/// fn main() { +/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); +/// // prevent earlier writes from being moved beyond this point +/// compiler_fence(Ordering::Release); +/// IS_READY.store(true, Ordering::Relaxed); +/// } +/// +/// fn signal_handler() { +/// if IS_READY.load(Ordering::Relaxed) { +/// assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); +/// } +/// } +/// ``` +/// /// [`fence`]: fn.fence.html /// [`Ordering`]: enum.Ordering.html /// [`Acquire`]: enum.Ordering.html#variant.Acquire @@ -1689,8 +1737,9 @@ pub fn fence(order: Ordering) { /// [`Release`]: enum.Ordering.html#variant.Release /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed +/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt #[inline] -#[unstable(feature = "compiler_fences", issue = "41091")] +#[stable(feature = "compiler_fences", since = "1.21.0")] pub fn compiler_fence(order: Ordering) { unsafe { match order { diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index ab2022b1824ca..1ba9d78f9de89 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -27,7 +27,6 @@ #![feature(inclusive_range_syntax)] #![feature(iter_rfind)] #![feature(nonzero)] -#![feature(ord_max_min)] #![feature(rand)] #![feature(raw)] #![feature(refcell_replace_swap)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index b57067e35e9d9..95fdac315da21 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -276,7 +276,6 @@ #![feature(macro_reexport)] #![feature(macro_vis_matcher)] #![feature(needs_panic_runtime)] -#![feature(needs_drop)] #![feature(never_type)] #![feature(num_bits_bytes)] #![feature(old_wrapping)] diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 2eabb46441b32..4d0ae13c65e3f 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -147,7 +147,7 @@ impl TcpStream { /// connection request. /// /// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html - #[unstable(feature = "tcpstream_connect_timeout", issue = "43079")] + #[stable(feature = "tcpstream_connect_timeout", since = "1.21.0")] pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result { net_imp::TcpStream::connect_timeout(addr, timeout).map(TcpStream) }