From cf318c3718b0fc78659cab4595c41ad1a5998564 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:17:50 -0500 Subject: [PATCH 01/10] bootstrap: use shasum(1) on NetBSD build hosts NetBSD doesn't ship with sha256sum. The openssl build will probably try to use perl anyway, so using perl's shasum is reasonable. --- src/bootstrap/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 8173903c03440..f357c5dc2d892 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -366,7 +366,7 @@ impl Step for Openssl { if !ok { panic!("failed to download openssl source") } - let mut shasum = if target.contains("apple") { + let mut shasum = if target.contains("apple") || build.build.contains("netbsd") { let mut cmd = Command::new("shasum"); cmd.arg("-a").arg("256"); cmd From ab89870a1b5e66ae36390ec59d7b68ffa706a49b Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:22:39 -0500 Subject: [PATCH 02/10] bootstrap: use tar -z on extract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tar(1) programs—such as NetBSD's—do not automatically decompress. --- src/bootstrap/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f357c5dc2d892..3267a3b88485c 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -386,7 +386,7 @@ impl Step for Openssl { let dst = build.openssl_install_dir(target).unwrap(); drop(fs::remove_dir_all(&obj)); drop(fs::remove_dir_all(&dst)); - build.run(Command::new("tar").arg("xf").arg(&tarball).current_dir(&out)); + build.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out)); let mut configure = Command::new(obj.join("Configure")); configure.arg(format!("--prefix={}", dst.display())); From a08822c7a7cb5b704331717a2229d04aaa930291 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Sun, 10 Sep 2017 10:42:24 -0500 Subject: [PATCH 03/10] bootstrap: always use shasum instead of sha256sum --- src/bootstrap/native.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 3267a3b88485c..449c7d55df2ce 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -366,12 +366,10 @@ impl Step for Openssl { if !ok { panic!("failed to download openssl source") } - let mut shasum = if target.contains("apple") || build.build.contains("netbsd") { + let mut shasum = { let mut cmd = Command::new("shasum"); cmd.arg("-a").arg("256"); cmd - } else { - Command::new("sha256sum") }; let output = output(&mut shasum.arg(&tmp)); let found = output.split_whitespace().next().unwrap(); From 07416452304b2c0b41597fdfe63f4b3b00aeecd9 Mon Sep 17 00:00:00 2001 From: "leonardo.yvens" Date: Sun, 17 Sep 2017 13:04:49 -0300 Subject: [PATCH 04/10] Remove unused str_eq lang item It's not a lang item anymore. Also remove outdated note. --- src/libcore/str/mod.rs | 3 --- src/librustc/middle/lang_items.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d4fef45ae4e8f..bfbc0b9004ccd 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1400,9 +1400,6 @@ Section: Comparing strings */ /// Bytewise slice equality -/// NOTE: This function is (ab)used in rustc::middle::trans::_match -/// to compare &[u8] byte slices that are not necessarily valid UTF-8. -#[lang = "str_eq"] #[inline] fn eq_slice(a: &str, b: &str) -> bool { a.as_bytes() == b.as_bytes() diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 7a6f4fdbb03ac..2dd55fcd121a6 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -281,8 +281,6 @@ language_item_table! { EqTraitLangItem, "eq", eq_trait; OrdTraitLangItem, "ord", ord_trait; - StrEqFnLangItem, "str_eq", str_eq_fn; - // A number of panic-related lang items. The `panic` item corresponds to // divide-by-zero and various panic cases with `match`. The // `panic_bounds_check` item is for indexing arrays. From 203d71f50706ab401173e91d1a4c7e593e2762e7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 14 Sep 2017 00:20:04 +0200 Subject: [PATCH 05/10] Add pub visibility for methods as well --- src/librustdoc/html/render.rs | 6 ++++-- src/test/rustdoc/pub-method.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/test/rustdoc/pub-method.rs diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 500b75ec659a1..9d1bf6663ffd1 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2588,7 +2588,8 @@ fn render_assoc_item(w: &mut fmt::Formatter, href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor) } }; - let mut head_len = format!("{}{}{:#}fn {}{:#}", + let mut head_len = format!("{}{}{}{:#}fn {}{:#}", + VisSpace(&meth.visibility), ConstnessSpace(constness), UnsafetySpace(unsafety), AbiSpace(abi), @@ -2600,8 +2601,9 @@ fn render_assoc_item(w: &mut fmt::Formatter, } else { (0, true) }; - write!(w, "{}{}{}fn {name}\ + write!(w, "{}{}{}{}fn {name}\ {generics}{decl}{where_clause}", + VisSpace(&meth.visibility), ConstnessSpace(constness), UnsafetySpace(unsafety), AbiSpace(abi), diff --git a/src/test/rustdoc/pub-method.rs b/src/test/rustdoc/pub-method.rs new file mode 100644 index 0000000000000..5998734e4a20c --- /dev/null +++ b/src/test/rustdoc/pub-method.rs @@ -0,0 +1,31 @@ +// 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. + +// ignore-tidy-linelength +// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports + +#![crate_name = "foo"] + +// @has foo/fn.bar.html +// @has - '//*[@class="rust fn"]' 'pub fn bar() -> ' +/// foo +pub fn bar() -> usize { + 2 +} + +// @has foo/struct.Foo.html +// @has - '//*[@class="method"]' 'pub fn new()' +// @has - '//*[@class="method"]' 'fn not_pub()' +pub struct Foo(usize); + +impl Foo { + pub fn new() -> Foo { Foo(0) } + fn not_pub() {} +} From c9099ff11b1d44a4942f448750cafe8e5c2fd915 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Wed, 20 Sep 2017 01:25:47 -0400 Subject: [PATCH 06/10] fix an incorrect assertion in the doc example for `std::io::copy` --- src/libstd/io/util.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 88f4214296d9c..bff4e5caaa16f 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -40,9 +40,10 @@ use mem; /// /// io::copy(&mut reader, &mut writer)?; /// -/// assert_eq!(reader, &writer[..]); +/// assert_eq!(&b"hello"[..], &writer[..]); /// # Ok(()) /// # } +/// # foo().unwrap(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn copy(reader: &mut R, writer: &mut W) -> io::Result From 66a31c7dc167a60bd8719e3f7bf2ae89ac781cff Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 20 Sep 2017 15:25:44 +0200 Subject: [PATCH 07/10] Make `-Z borrowck-mir` imply that `EndRegion`'s should be emitted. --- src/librustc/session/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index df5a2648e270c..bdff6535713d2 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -411,7 +411,8 @@ impl Session { } pub fn emit_end_regions(&self) -> bool { self.opts.debugging_opts.emit_end_regions || - (self.opts.debugging_opts.mir_emit_validate > 0) + (self.opts.debugging_opts.mir_emit_validate > 0) || + self.opts.debugging_opts.borrowck_mir } pub fn lto(&self) -> bool { self.opts.cg.lto From 5bafba47592688e1f0dce051326d33b5bc8491ba Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Wed, 20 Sep 2017 14:08:30 -0500 Subject: [PATCH 08/10] Fix librusc/README.md diagram --- src/librustc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/README.md b/src/librustc/README.md index 59d346db4af4d..87de284d011b3 100644 --- a/src/librustc/README.md +++ b/src/librustc/README.md @@ -37,7 +37,7 @@ incremental improves that may change.) The dependency structure of these crates is roughly a diamond: -```` +``` rustc_driver / | \ / | \ From 548686ff12322f948652ee6523074b2ce6d2bb06 Mon Sep 17 00:00:00 2001 From: Havvy Date: Sat, 16 Sep 2017 20:40:05 -0700 Subject: [PATCH 09/10] Document stable size_of primitives and pointer size guarantees --- src/libcore/mem.rs | 48 ++++++++++++++++++++++++++++++++++-- src/libstd/primitive_docs.rs | 8 ++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 3e24623dad895..e98dab739cb02 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -177,15 +177,59 @@ pub fn forget(t: T) { /// Returns the size of a type in bytes. /// -/// More specifically, this is the offset in bytes between successive -/// items of the same type, including alignment padding. +/// More specifically, this is the offset in bytes between successive elements +/// in an array with that item type including alignment padding. Thus, for any +/// type `T` and length `n`, `[T; n]` has a size of `n * size_of::()`. +/// +/// In general, the size of a type is not stable across compilations, but +/// specific types such as primitives are. +/// +/// The following table gives the size for primitives. +/// +/// Type | size_of::\() +/// ---- | --------------- +/// () | 0 +/// u8 | 1 +/// u16 | 2 +/// u32 | 4 +/// u64 | 8 +/// i8 | 1 +/// i16 | 2 +/// i32 | 4 +/// i64 | 8 +/// f32 | 4 +/// f64 | 8 +/// char | 4 +/// +/// Furthermore, `usize` and `isize` have the same size. +/// +/// The types `*const T`, `&T`, `Box`, `Option<&T>`, and `Option>` all have +/// the same size. If `T` is Sized, all of those types have the same size as `usize`. +/// +/// The mutability of a pointer does not change its size. As such, `&T` and `&mut T` +/// have the same size. Likewise for `*const T` and `*mut T`. /// /// # Examples /// /// ``` /// use std::mem; /// +/// // Some primitives /// assert_eq!(4, mem::size_of::()); +/// assert_eq!(8, mem::size_of::()); +/// assert_eq!(0, mem::size_of::<()>()); +/// +/// // Some arrays +/// assert_eq!(8, mem::size_of::<[i32; 2]>()); +/// assert_eq!(12, mem::size_of::<[i32; 3]>()); +/// assert_eq!(0, mem::size_of::<[i32; 0]>()); +/// +/// +/// // Pointer size equality +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::<*const i32>()); +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); +/// assert_eq!(mem::size_of::>(), mem::size_of::>>()); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 76ef36cc9a733..1edb35d8fe741 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -710,6 +710,10 @@ mod prim_u128 { } // /// The pointer-sized signed integer type. /// +/// The size of this primitive is how many bytes it takes to reference any +/// location in memory. For example, on a 32 bit target, this is 4 bytes +/// and on a 64 bit target, this is 8 bytes. +/// /// *[See also the `std::isize` module](isize/index.html).* /// /// However, please note that examples are shared between primitive integer @@ -722,6 +726,10 @@ mod prim_isize { } // /// The pointer-sized unsigned integer type. /// +/// The size of this primitive is how many bytes it takes to reference any +/// location in memory. For example, on a 32 bit target, this is 4 bytes +/// and on a 64 bit target, this is 8 bytes. +/// /// *[See also the `std::usize` module](usize/index.html).* /// /// However, please note that examples are shared between primitive integer From 5463aa06b8d3f9dd02225924ff726a14af0878a6 Mon Sep 17 00:00:00 2001 From: Marcus Buffett Date: Thu, 21 Sep 2017 12:15:10 -0700 Subject: [PATCH 10/10] Catch IOError If config.toml doesn't exist, then an IOError will be raised on the `with open(...)` line. Prior to e788fa7, this was caught because the `except` clause didn't specify what exceptions it caught, so both IOError and OSError were caught --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index f12da29c45b02..4a8c3dcebcb49 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -682,7 +682,7 @@ def bootstrap(): try: with open(args.config or 'config.toml') as config: build.config_toml = config.read() - except OSError: + except (OSError, IOError): pass if '\nverbose = 2' in build.config_toml: