From 67574ccd5352746c8040de05f469a3bb86e2fa97 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Feb 2017 15:08:30 -0800 Subject: [PATCH 01/12] Don't include directory names in shasums Right now we just run `shasum` on an absolute path but right now the shasum files only include filenames, so let's use `current_dir` and just the file name to only have the file name emitted. --- src/tools/build-manifest/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 8c15a6630a33c..8afe0cfd102b0 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -350,7 +350,8 @@ impl Builder { fn hash(&self, path: &Path) -> String { let sha = t!(Command::new("shasum") .arg("-a").arg("256") - .arg(path) + .arg(path.file_name().unwrap()) + .current_dir(path.parent().unwrap()) .output()); assert!(sha.status.success()); From de59d5d73775f8ccf948480cbd5d90dc72e1b40f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Feb 2017 20:49:58 -0800 Subject: [PATCH 02/12] Actually fix manifest generation The previous fix contained an error where `toml::encode` returned a runtime error, so this version just constructs a literal `toml::Value`. --- src/tools/build-manifest/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 548a11439f5cc..eceba7411ac5c 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -178,8 +178,8 @@ impl Builder { // and wrap it up in a `Value::Table`. let mut manifest = BTreeMap::new(); manifest.insert("manifest-version".to_string(), - toml::encode(&manifest_version)); - manifest.insert("date".to_string(), toml::encode(&date)); + toml::Value::String(manifest_version)); + manifest.insert("date".to_string(), toml::Value::String(date)); manifest.insert("pkg".to_string(), toml::encode(&pkg)); let manifest = toml::Value::Table(manifest).to_string(); From 1095082eea65a4bfb577221ae1cac07330770aaa Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 9 Feb 2017 17:55:39 +0100 Subject: [PATCH 03/12] remove wrong packed struct test --- src/test/run-pass/dst-field-align.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/run-pass/dst-field-align.rs b/src/test/run-pass/dst-field-align.rs index cf2acfe986c21..3a2cf28a24f86 100644 --- a/src/test/run-pass/dst-field-align.rs +++ b/src/test/run-pass/dst-field-align.rs @@ -55,12 +55,6 @@ fn main() { // The pointers should be the same assert_eq!(ptr1, ptr2); - // Test that packed structs are handled correctly - let p : Packed = Packed { a: 0, b: 13 }; - assert_eq!(p.b.get(), 13); - let p : &Packed = &p; - assert_eq!(p.b.get(), 13); - // Test that nested DSTs work properly let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; assert_eq!(f.b.b.get(), 17); From c7f9811abab9289eac9b577aba4c60a5afb0bef4 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 9 Feb 2017 17:58:26 +0100 Subject: [PATCH 04/12] removed unused struct --- src/test/run-pass/dst-field-align.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/run-pass/dst-field-align.rs b/src/test/run-pass/dst-field-align.rs index 3a2cf28a24f86..c36833f2fb627 100644 --- a/src/test/run-pass/dst-field-align.rs +++ b/src/test/run-pass/dst-field-align.rs @@ -25,12 +25,6 @@ struct Baz { a: T } -#[repr(packed)] -struct Packed { - a: u8, - b: T -} - struct HasDrop { ptr: Box, data: T From b3937ea862e15321e85537ac6bd63ad51099c23f Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 9 Feb 2017 13:58:48 -0500 Subject: [PATCH 05/12] Explicitly mention that `Vec::reserve` is based on len not capacity I spent a good chunk of time tracking down a buffer overrun bug that resulted from me mistakenly thinking that `reserve` was based on the current capacity not the current length. It would be helpful if this were called out explicitly in the docs. --- src/libcollections/vec.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index dc0f33d9bc3e0..3873b3535a07b 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -437,7 +437,9 @@ impl Vec { /// Reserves capacity for at least `additional` more elements to be inserted /// in the given `Vec`. The collection may reserve more space to avoid - /// frequent reallocations. + /// frequent reallocations. After calling `reserve`, capacity will be + /// greater than or equal to `self.len() + additional`. Does nothing if + /// capacity is already sufficient. /// /// # Panics /// @@ -456,8 +458,9 @@ impl Vec { } /// Reserves the minimum capacity for exactly `additional` more elements to - /// be inserted in the given `Vec`. Does nothing if the capacity is already - /// sufficient. + /// be inserted in the given `Vec`. After calling `reserve_exact`, + /// capacity will be greater than or equal to `self.len() + additional`. + /// Does nothing if the capacity is already sufficient. /// /// Note that the allocator may give the collection more space than it /// requests. Therefore capacity can not be relied upon to be precisely From e491f399147aaf09f631878d009396fc5400ddfd Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 10 Feb 2017 00:30:02 +0000 Subject: [PATCH 06/12] Update 1.15.1 relnotes --- RELEASES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 2df1a83db81ff..1de44ef7e6d05 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,9 +1,11 @@ -Version 1.15.1 (2017-02-08) +Version 1.15.1 (2017-02-09) =========================== * [Fix IntoIter::as_mut_slice's signature][39466] +* [Compile compiler builtins with `-fPIC` on 32-bit platforms][39523] [39466]: https://github.com/rust-lang/rust/pull/39466 +[39523]: https://github.com/rust-lang/rust/pull/39523 Version 1.15.0 (2017-02-02) From 5cc5e0851e5bd14b9855462408ecb9058ed5eaad Mon Sep 17 00:00:00 2001 From: Rob Speer Date: Thu, 19 Jan 2017 02:51:29 -0500 Subject: [PATCH 07/12] Fix a misleading statement in `Iterator.nth()` The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well. The way I read the documentation, I assumed that `nth(0)` would not discard anything (as there are 0 preceding elements), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing. --- src/libcore/iter/iterator.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 3b406873d4b19..0e14a93d25396 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -209,7 +209,10 @@ pub trait Iterator { /// Returns the `n`th element of the iterator. /// - /// Note that all preceding elements will be consumed (i.e. discarded). + /// Note that all preceding elements, as well as the returned element, will be + /// consumed. That means that the preceding elements will be discarded, and also + /// that calling `nth(0)` multiple times on the same iterator will return different + /// objects. /// /// Like most indexing operations, the count starts from zero, so `nth(0)` /// returns the first value, `nth(1)` the second, and so on. From ebf29ef0733ec0ac13ef16eb42bac17e3b94da3c Mon Sep 17 00:00:00 2001 From: Rob Speer Date: Thu, 19 Jan 2017 02:53:33 -0500 Subject: [PATCH 08/12] Rephrase my proposed edit ("objects" -> "elements") --- src/libcore/iter/iterator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 0e14a93d25396..4a8c8b53a8c29 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -212,7 +212,7 @@ pub trait Iterator { /// Note that all preceding elements, as well as the returned element, will be /// consumed. That means that the preceding elements will be discarded, and also /// that calling `nth(0)` multiple times on the same iterator will return different - /// objects. + /// elements. /// /// Like most indexing operations, the count starts from zero, so `nth(0)` /// returns the first value, `nth(1)` the second, and so on. From 11d36aec8317dba64e30b98aad75c70e4eed6b3e Mon Sep 17 00:00:00 2001 From: Rob Speer Date: Fri, 10 Feb 2017 01:35:29 -0500 Subject: [PATCH 09/12] iterator docs: Move paragraph about discarding; clarify "consumed" --- src/libcore/iter/iterator.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 4a8c8b53a8c29..d41767cce18fe 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -209,14 +209,14 @@ pub trait Iterator { /// Returns the `n`th element of the iterator. /// - /// Note that all preceding elements, as well as the returned element, will be - /// consumed. That means that the preceding elements will be discarded, and also - /// that calling `nth(0)` multiple times on the same iterator will return different - /// elements. - /// /// Like most indexing operations, the count starts from zero, so `nth(0)` /// returns the first value, `nth(1)` the second, and so on. /// + /// Note that all preceding elements, as well as the returned element, will be + /// consumed from the iterator. That means that the preceding elements will be + /// discarded, and also that calling `nth(0)` multiple times on the same iterator + /// will return different elements. + /// /// `nth()` will return [`None`] if `n` is greater than or equal to the length of the /// iterator. /// From a8364acafb9bd7dff2aff6ca2007cbfd5463260c Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 10 Feb 2017 16:28:42 -0200 Subject: [PATCH 10/12] Allow rustc data structures compile to android flock structure is defined in asm*/fcntl.h. This file on android is generated from the linux kernel source, so they are the same. --- src/librustc_data_structures/flock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index 33d71ba862643..26417e3ba7cd1 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -27,7 +27,7 @@ mod imp { use std::io; use libc; - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] mod os { use libc; From 5c295110fddf386b0a42b3896541c5669d333b30 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Fri, 10 Feb 2017 18:44:32 +0000 Subject: [PATCH 11/12] Updated installing nightly instructions --- src/doc/book/nightly-rust.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/doc/book/nightly-rust.md b/src/doc/book/nightly-rust.md index 25570cb5503c9..f55bb0784202a 100644 --- a/src/doc/book/nightly-rust.md +++ b/src/doc/book/nightly-rust.md @@ -6,10 +6,13 @@ process, see ‘[Stability as a deliverable][stability]’. [stability]: http://blog.rust-lang.org/2014/10/30/Stability.html -To install nightly Rust, you can use `rustup.sh`: +To install nightly Rust, you can use [rustup.rs][rustup]: + +[rustup]: https://rustup.rs ```bash -$ curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly +$ curl https://sh.rustup.rs -sSf | sh +$ rustup install nightly ``` If you're concerned about the [potential insecurity][insecurity] of using `curl @@ -17,31 +20,28 @@ If you're concerned about the [potential insecurity][insecurity] of using `curl use a two-step version of the installation and examine our installation script: ```bash -$ curl -f -L https://static.rust-lang.org/rustup.sh -O -$ sh rustup.sh --channel=nightly +$ curl https://sh.rustup.rs -sSf -o rustup.sh +$ sh rustup.sh +$ rustup install nightly ``` [insecurity]: http://curlpipesh.tumblr.com -If you're on Windows, please download either the [32-bit installer][win32] or -the [64-bit installer][win64] and run it. +If you're on Windows, please download the [rustup installer][installer] +and run it. -[win32]: https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.msi -[win64]: https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.msi +[installer]: https://win.rustup.rs ## Uninstalling If you decide you don't want Rust anymore, we'll be a bit sad, but that's okay. Not every programming language is great for everyone. Just run the uninstall -script: +command: ```bash -$ sudo /usr/local/lib/rustlib/uninstall.sh +$ rustup self uninstall ``` -If you used the Windows installer, re-run the `.msi` and it will give you -an uninstall option. - Some people, and somewhat rightfully so, get very upset when we tell you to `curl | sh`. Basically, when you do this, you are trusting that the good people who maintain Rust aren't going to hack your computer and do bad things. From ca92c516820e760173c40a9cbb42daef8111c93e Mon Sep 17 00:00:00 2001 From: whataloadofwhat Date: Fri, 10 Feb 2017 17:55:00 +0000 Subject: [PATCH 12/12] Change std::panicking::try::Data into a union No longer potentially call `mem::uninitialized::()` Fixes #39432 --- src/libstd/lib.rs | 1 + src/libstd/panicking.rs | 36 ++++++++++---------------- src/test/run-pass/catch-unwind-bang.rs | 17 ++++++++++++ 3 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 src/test/run-pass/catch-unwind-bang.rs diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 3a552c060a9b9..070690773b6c4 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -303,6 +303,7 @@ #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] +#![feature(untagged_unions)] #![feature(unwind_attributes)] #![feature(vec_push_all)] #![feature(zero_one)] diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index d76e8816ca45f..3fba49345e63d 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -389,28 +389,23 @@ pub use realstd::rt::update_panic_count; /// Invoke a closure, capturing the cause of an unwinding panic if one occurs. pub unsafe fn try R>(f: F) -> Result> { - struct Data { + #[allow(unions_with_drop_fields)] + union Data { f: F, r: R, } // We do some sketchy operations with ownership here for the sake of - // performance. The `Data` structure is never actually fully valid, but - // instead it always contains at least one uninitialized field. We can only - // pass pointers down to `__rust_maybe_catch_panic` (can't pass objects by - // value), so we do all the ownership tracking here manully. + // performance. We can only pass pointers down to + // `__rust_maybe_catch_panic` (can't pass objects by value), so we do all + // the ownership tracking here manually using a union. // - // Note that this is all invalid if any of these functions unwind, but the - // whole point of this function is to prevent that! As a result we go - // through a transition where: + // We go through a transition where: // - // * First, only the closure we're going to call is initialized. The return - // value is uninitialized. + // * First, we set the data to be the closure that we're going to call. // * When we make the function call, the `do_call` function below, we take - // ownership of the function pointer, replacing it with uninitialized - // data. At this point the `Data` structure is entirely uninitialized, but - // it won't drop due to an unwind because it's owned on the other side of - // the catch panic. + // ownership of the function pointer. At this point the `Data` union is + // entirely uninitialized. // * If the closure successfully returns, we write the return value into the // data's return slot. Note that `ptr::write` is used as it's overwriting // uninitialized data. @@ -418,11 +413,10 @@ pub unsafe fn try R>(f: F) -> Result> { // in one of two states: // // 1. The closure didn't panic, in which case the return value was - // filled in. We have to be careful to `forget` the closure, - // however, as ownership was passed to the `do_call` function. + // filled in. We move it out of `data` and return it. // 2. The closure panicked, in which case the return value wasn't - // filled in. In this case the entire `data` structure is invalid, - // so we forget the entire thing. + // filled in. In this case the entire `data` union is invalid, so + // there is no need to drop anything. // // Once we stack all that together we should have the "most efficient' // method of calling a catch panic whilst juggling ownership. @@ -430,7 +424,6 @@ pub unsafe fn try R>(f: F) -> Result> { let mut any_vtable = 0; let mut data = Data { f: f, - r: mem::uninitialized(), }; let r = __rust_maybe_catch_panic(do_call::, @@ -439,12 +432,9 @@ pub unsafe fn try R>(f: F) -> Result> { &mut any_vtable); return if r == 0 { - let Data { f, r } = data; - mem::forget(f); debug_assert!(update_panic_count(0) == 0); - Ok(r) + Ok(data.r) } else { - mem::forget(data); update_panic_count(-1); debug_assert!(update_panic_count(0) == 0); Err(mem::transmute(raw::TraitObject { diff --git a/src/test/run-pass/catch-unwind-bang.rs b/src/test/run-pass/catch-unwind-bang.rs new file mode 100644 index 0000000000000..df54ec90022ee --- /dev/null +++ b/src/test/run-pass/catch-unwind-bang.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn worker() -> ! { + panic!() +} + +fn main() { + std::panic::catch_unwind(worker).unwrap_err(); +}