From f51e64f7e9aa7c7a6827e3843feb0ed39e145a74 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 3 Aug 2017 19:09:04 +0200 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 880caa2ade5..36a3550ecec 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 -- cgit 1.4.1-3-g733a5 From 01000fb5c65cf6f8ed8a845bf85dff5f2fe2949f Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 3 Aug 2017 21:17:31 +0200 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 36a3550ecec..86bdf606980 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 -- cgit 1.4.1-3-g733a5 From e63d979e22d6c0b82812a944151db3d3f54ff2e4 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Fri, 4 Aug 2017 13:03:58 +0200 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 86bdf606980..30495f29745 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 -- cgit 1.4.1-3-g733a5 From b272f6ca05e9210dbe6c605a301d5a16007f322f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 18 Aug 2017 12:04:45 -0700 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 4496de09b25..866b65ac7e4 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. -- cgit 1.4.1-3-g733a5 From e0f0fd08b5e823561848c9541ac432eb30b976bd Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 18 Aug 2017 15:56:13 -0700 Subject: Correct has_root() on Redox --- src/libstd/path.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 866b65ac7e4..5757d447c54 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, } -- cgit 1.4.1-3-g733a5 From ab48de88472f19596ba2a67ff4e8a8c1c4015989 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 22 Aug 2017 08:17:05 -0700 Subject: Use cfg! instead of #[cfg] --- src/libstd/path.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 5757d447c54..32e1781c3c4 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()) } -- cgit 1.4.1-3-g733a5 From c987f30049c954be378f847c8bef730fdb95cab8 Mon Sep 17 00:00:00 2001 From: Nathaniel Ringo Date: Tue, 22 Aug 2017 11:56:38 -0500 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 6746754ebc3..76ef36cc9a7 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 -- cgit 1.4.1-3-g733a5 From fe2d661931852c4303b45bed472640bd0b32448f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 22 Aug 2017 10:33:26 -0700 Subject: Simplify code for handling Redox paths --- src/libstd/path.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 32e1781c3c4..d529b2153e1 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, } -- cgit 1.4.1-3-g733a5 From 1d5ee636d7409164a8c5df0f20a2c508449c672a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 22 Aug 2017 18:03:09 -0400 Subject: 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(-) (limited to 'src/libstd') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 83feb595bce..ee103c803f5 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(); -- cgit 1.4.1-3-g733a5