From f51e64f7e9aa7c7a6827e3843feb0ed39e145a74 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 3 Aug 2017 19:09:04 +0200 Subject: [PATCH 01/13] Point "deref coercions" links to new book Currently the link on doc.rust-lang.org is semi-broken; it links to a page that links to the exact page in the first edition in the book, or to the index of the second edition of the book. If the second editions is the recommended one now, we should point the links at that one. It seems that in the mean time, the links have been updated to point directly to the first edition of the book, but that hasn't made it onto the stable channel yet. By the time this commit makes it onto the stable channel, the second edition of the book should be complete enough. At least the part about deref coercions is. --- src/libstd/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 880caa2ade5d8..36a3550ececf0 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -203,7 +203,7 @@ //! [`use`]: ../book/first-edition/crates-and-modules.html#importing-modules-with-use //! [crate root]: ../book/first-edition/crates-and-modules.html#basic-terminology-crates-and-modules //! [crates.io]: https://crates.io -//! [deref coercions]: ../book/first-edition/deref-coercions.html +//! [deref coercions]: ../book/second-edition/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods //! [files]: fs/struct.File.html //! [multithreading]: thread/index.html //! [other]: #what-is-in-the-standard-library-documentation From 01000fb5c65cf6f8ed8a845bf85dff5f2fe2949f Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 3 Aug 2017 21:17:31 +0200 Subject: [PATCH 02/13] Replace space in Markdown link label With the space, the tidy check does not recognize it as a link label. See also the comment above in line_is_url() in src/tools/tidy/src/style.rs. --- src/libstd/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 36a3550ececf0..86bdf606980a9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -80,8 +80,8 @@ //! //! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also //! called 'slice'). Many method calls on [`String`] and [`Vec`] are actually -//! calls to methods on [`str`] and [`[T]`][slice] respectively, via [deref -//! coercions]. +//! calls to methods on [`str`] and [`[T]`][slice] respectively, via +//! [deref-coercions]. //! //! Third, the standard library defines [The Rust Prelude], a small collection //! of items - mostly traits - that are imported into every module of every @@ -203,7 +203,7 @@ //! [`use`]: ../book/first-edition/crates-and-modules.html#importing-modules-with-use //! [crate root]: ../book/first-edition/crates-and-modules.html#basic-terminology-crates-and-modules //! [crates.io]: https://crates.io -//! [deref coercions]: ../book/second-edition/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods +//! [deref-coercions]: ../book/second-edition/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods //! [files]: fs/struct.File.html //! [multithreading]: thread/index.html //! [other]: #what-is-in-the-standard-library-documentation From e63d979e22d6c0b82812a944151db3d3f54ff2e4 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Fri, 4 Aug 2017 13:03:58 +0200 Subject: [PATCH 03/13] Docs: restore link text after renaming anchor The text does not need the hyphen, but the anchor name does. --- src/libstd/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 86bdf606980a9..30495f297453d 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -80,8 +80,8 @@ //! //! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also //! called 'slice'). Many method calls on [`String`] and [`Vec`] are actually -//! calls to methods on [`str`] and [`[T]`][slice] respectively, via -//! [deref-coercions]. +//! calls to methods on [`str`] and [`[T]`][slice] respectively, via [deref +//! coercions][deref-coercions]. //! //! Third, the standard library defines [The Rust Prelude], a small collection //! of items - mostly traits - that are imported into every module of every From b272f6ca05e9210dbe6c605a301d5a16007f322f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 18 Aug 2017 12:04:45 -0700 Subject: [PATCH 04/13] redox: Require scheme for path to be absolute Redox paths are problematic. It would make sense to add a `Scheme` variant to the `std::path::Component` enum; but that would presumably be a breaking change due to exhaustive matching. Alternately it could use the existing `Prefix` variant, like Windows, but none of the existing types of prefix make sense, Redox only has one kind, and adding a new variant to that enum has the same issue as `Component`. --- src/libstd/path.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 4496de09b2590..866b65ac7e4c3 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1685,8 +1685,16 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - // FIXME: Remove target_os = "redox" and allow Redox prefixes - self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some()) + #[cfg(not(target_os = "redox"))] + { + self.has_root() && (cfg!(unix) || self.prefix().is_some()) + } + #[cfg(target_os = "redox")] + { + // FIXME: Allow Redox prefixes + use os::unix::ffi::OsStrExt; + self.as_os_str().as_bytes().split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') + } } /// Returns `true` if the `Path` is relative, i.e. not absolute. From b8f4e74cbc938d3448507d422c98061c2b71c922 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 18 Aug 2017 17:09:51 +0200 Subject: [PATCH 05/13] Remove outline when details have focus --- src/librustdoc/html/static/rustdoc.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index ee94f0baeb9a3..26a64f6cd2245 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -126,6 +126,10 @@ p { margin: 0 0 .6em 0; } +summary { + outline: none; +} + code, pre { font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace; white-space: pre-wrap; From e0f0fd08b5e823561848c9541ac432eb30b976bd Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 18 Aug 2017 15:56:13 -0700 Subject: [PATCH 06/13] Correct has_root() on Redox --- src/libstd/path.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 866b65ac7e4c3..5757d447c54d0 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -323,6 +323,20 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { mem::transmute(s) } +// Detect scheme on Redox +#[inline] +#[allow(unused_variables)] +fn has_scheme(s: &[u8]) -> bool { + #[cfg(target_os = "redox")] + { + s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') + } + #[cfg(not(target_os = "redox"))] + { + false + } +} + //////////////////////////////////////////////////////////////////////////////// // Cross-platform, iterator-independent parsing //////////////////////////////////////////////////////////////////////////////// @@ -605,6 +619,9 @@ pub struct Components<'a> { // normalization, e.g. \\server\share == \\server\share\. has_physical_root: bool, + // For Redox + has_scheme: bool, + // The iterator is double-ended, and these two states keep track of what has // been produced from either end front: State, @@ -725,7 +742,7 @@ impl<'a> Components<'a> { /// Is the *original* path rooted? fn has_root(&self) -> bool { - if self.has_physical_root { + if self.has_physical_root || self.has_scheme { return true; } if let Some(p) = self.prefix { @@ -1692,8 +1709,7 @@ impl Path { #[cfg(target_os = "redox")] { // FIXME: Allow Redox prefixes - use os::unix::ffi::OsStrExt; - self.as_os_str().as_bytes().split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') + has_scheme(self.as_u8_slice()) } } @@ -2059,6 +2075,7 @@ impl Path { path: self.as_u8_slice(), prefix, has_physical_root: has_physical_root(self.as_u8_slice(), prefix), + has_scheme: has_scheme(self.as_u8_slice()), front: State::Prefix, back: State::Body, } From d46660edc97156865a9f99b03c2a94e4ee5c11b9 Mon Sep 17 00:00:00 2001 From: Steffen Date: Mon, 21 Aug 2017 17:17:27 +0200 Subject: [PATCH 07/13] libproc_macro docs: fix brace and bracket mixup the documentation indicates that brace is `[` but maps to token::Brace which (expectedly) is `{`. Just a little confusion in the docs. --- src/libproc_macro/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 6a71e67676ae4..4fec02a64aed3 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -246,9 +246,9 @@ pub enum TokenNode { pub enum Delimiter { /// `( ... )` Parenthesis, - /// `[ ... ]` - Brace, /// `{ ... }` + Brace, + /// `[ ... ]` Bracket, /// An implicit delimiter, e.g. `$var`, where $var is `...`. None, From ab48de88472f19596ba2a67ff4e8a8c1c4015989 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 22 Aug 2017 08:17:05 -0700 Subject: [PATCH 08/13] Use cfg! instead of #[cfg] --- src/libstd/path.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 5757d447c54d0..32e1781c3c45c 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -327,14 +327,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { #[inline] #[allow(unused_variables)] fn has_scheme(s: &[u8]) -> bool { - #[cfg(target_os = "redox")] - { - s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') - } - #[cfg(not(target_os = "redox"))] - { - false - } + cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') } //////////////////////////////////////////////////////////////////////////////// @@ -1702,12 +1695,9 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - #[cfg(not(target_os = "redox"))] - { + if !cfg!(target_os = "redox") { self.has_root() && (cfg!(unix) || self.prefix().is_some()) - } - #[cfg(target_os = "redox")] - { + } else { // FIXME: Allow Redox prefixes has_scheme(self.as_u8_slice()) } From c987f30049c954be378f847c8bef730fdb95cab8 Mon Sep 17 00:00:00 2001 From: Nathaniel Ringo Date: Tue, 22 Aug 2017 11:56:38 -0500 Subject: [PATCH 09/13] Mention null_mut on the pointer primitive docs. Also adds a few mentions that both `*const` and `*mut` support functions, when only `*const` was mentioned before. --- src/libstd/primitive_docs.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 6746754ebc344..76ef36cc9a733 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -188,9 +188,10 @@ mod prim_unit { } /// Working with raw pointers in Rust is uncommon, /// typically limited to a few patterns. /// -/// Use the [`null`] function to create null pointers, and the [`is_null`] method -/// of the `*const T` type to check for null. The `*const T` type also defines -/// the [`offset`] method, for pointer math. +/// Use the [`null`] and [`null_mut`] functions to create null pointers, and the +/// [`is_null`] method of the `*const T` and `*mut T` types to check for null. +/// The `*const T` and `*mut T` types also define the [`offset`] method, for +/// pointer math. /// /// # Common ways to create raw pointers /// @@ -261,6 +262,7 @@ mod prim_unit { } /// *[See also the `std::ptr` module](ptr/index.html).* /// /// [`null`]: ../std/ptr/fn.null.html +/// [`null_mut`]: ../std/ptr/fn.null_mut.html /// [`is_null`]: ../std/primitive.pointer.html#method.is_null /// [`offset`]: ../std/primitive.pointer.html#method.offset /// [`into_raw`]: ../std/boxed/struct.Box.html#method.into_raw From fe2d661931852c4303b45bed472640bd0b32448f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 22 Aug 2017 10:33:26 -0700 Subject: [PATCH 10/13] Simplify code for handling Redox paths --- src/libstd/path.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 32e1781c3c45c..d529b2153e151 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -324,9 +324,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { } // Detect scheme on Redox -#[inline] -#[allow(unused_variables)] -fn has_scheme(s: &[u8]) -> bool { +fn has_redox_scheme(s: &[u8]) -> bool { cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') } @@ -612,9 +610,6 @@ pub struct Components<'a> { // normalization, e.g. \\server\share == \\server\share\. has_physical_root: bool, - // For Redox - has_scheme: bool, - // The iterator is double-ended, and these two states keep track of what has // been produced from either end front: State, @@ -735,7 +730,7 @@ impl<'a> Components<'a> { /// Is the *original* path rooted? fn has_root(&self) -> bool { - if self.has_physical_root || self.has_scheme { + if self.has_physical_root { return true; } if let Some(p) = self.prefix { @@ -1699,7 +1694,7 @@ impl Path { self.has_root() && (cfg!(unix) || self.prefix().is_some()) } else { // FIXME: Allow Redox prefixes - has_scheme(self.as_u8_slice()) + has_redox_scheme(self.as_u8_slice()) } } @@ -2064,8 +2059,8 @@ impl Path { Components { path: self.as_u8_slice(), prefix, - has_physical_root: has_physical_root(self.as_u8_slice(), prefix), - has_scheme: has_scheme(self.as_u8_slice()), + has_physical_root: has_physical_root(self.as_u8_slice(), prefix) || + has_redox_scheme(self.as_u8_slice()), front: State::Prefix, back: State::Body, } From 081f32ab6777e5dbd4cd444c3c1e5234d14be958 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Tue, 22 Aug 2017 13:28:39 -0500 Subject: [PATCH 11/13] Clarify windows build instructions in README The old wording made me think you were supposed to do `python x.py --build=msvc`, which is not the case. Specify that you need to use the target triple. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6ff6df0aec94..78a9f509bbcb4 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Windows build triples are: - `i686-pc-windows-msvc` - `x86_64-pc-windows-msvc` -The build triple can be specified by either specifying `--build=ABI` when +The build triple can be specified by either specifying `--build=` when invoking `x.py` commands, or by copying the `config.toml` file (as described in Building From Source), and modifying the `build` option under the `[build]` section. From b1e8c7215d6aad2ad1ae6f1375676cf92aa16f87 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 22 Aug 2017 12:45:10 -0700 Subject: [PATCH 12/13] Fix little-endian assumptions in run-pass/union/union-basic --- src/test/run-pass/union/union-basic.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/run-pass/union/union-basic.rs b/src/test/run-pass/union/union-basic.rs index de744520cc6be..079f6a6b641e9 100644 --- a/src/test/run-pass/union/union-basic.rs +++ b/src/test/run-pass/union/union-basic.rs @@ -10,10 +10,6 @@ // aux-build:union.rs -// FIXME: This test case makes little-endian assumptions. -// ignore-s390x -// ignore-sparc - extern crate union; use std::mem::{size_of, align_of, zeroed}; @@ -39,7 +35,7 @@ fn local() { assert_eq!(w.b, 0); w.a = 1; assert_eq!(w.a, 1); - assert_eq!(w.b, 1); + assert_eq!(w.b.to_le(), 1); } } @@ -60,7 +56,7 @@ fn xcrate() { assert_eq!(w.b, 0); w.a = 1; assert_eq!(w.a, 1); - assert_eq!(w.b, 1); + assert_eq!(w.b.to_le(), 1); } } From 1d5ee636d7409164a8c5df0f20a2c508449c672a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 22 Aug 2017 18:03:09 -0400 Subject: [PATCH 13/13] Thread spawning: don't run `min_stack` if the user has specified stack size. --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 83feb595bce51..ee103c803f542 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -374,7 +374,7 @@ impl Builder { { let Builder { name, stack_size } = self; - let stack_size = stack_size.unwrap_or(util::min_stack()); + let stack_size = stack_size.unwrap_or_else(util::min_stack); let my_thread = Thread::new(name); let their_thread = my_thread.clone();