From af221a221fe85bd4b0acaf3203d9f0977ea97f2e Mon Sep 17 00:00:00 2001 From: "Collin J. Sutton" Date: Sun, 8 Jan 2017 12:15:39 -0800 Subject: [PATCH 1/7] Updates to src/libcore/ops.rs for RFC#1228 (Placement Left Arrow) Also fixed a minor typo in docs for `core::ops::Place`. --- src/libcore/ops.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 40d941a8b27e0..939fac0503ce0 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -2747,7 +2747,7 @@ impl, U: ?Sized> CoerceUnsized<*const U> for *mut T {} #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} -/// Both `in (PLACE) EXPR` and `box EXPR` desugar into expressions +/// Both `PLACE <- EXPR` and `box EXPR` desugar into expressions /// that allocate an intermediate "place" that holds uninitialized /// state. The desugaring evaluates EXPR, and writes the result at /// the address returned by the `pointer` method of this trait. @@ -2762,7 +2762,7 @@ impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} /// converting the agent to an instance of the owning pointer, via the /// appropriate `finalize` method (see the `InPlace`. /// -/// If evaluating EXPR fails, then the destructor for the +/// If evaluating EXPR fails, then it is up to the destructor for the /// implementation of Place to clean up any intermediate state /// (e.g. deallocate box storage, pop a stack, etc). #[unstable(feature = "placement_new_protocol", issue = "27779")] @@ -2773,9 +2773,9 @@ pub trait Place { fn pointer(&mut self) -> *mut Data; } -/// Interface to implementations of `in (PLACE) EXPR`. +/// Interface to implementations of `PLACE <- EXPR`. /// -/// `in (PLACE) EXPR` effectively desugars into: +/// `PLACE <- EXPR` effectively desugars into: /// /// ```rust,ignore /// let p = PLACE; @@ -2788,7 +2788,7 @@ pub trait Place { /// } /// ``` /// -/// The type of `in (PLACE) EXPR` is derived from the type of `PLACE`; +/// The type of `PLACE <- EXPR` is derived from the type of `PLACE`; /// if the type of `PLACE` is `P`, then the final type of the whole /// expression is `P::Place::Owner` (see the `InPlace` and `Boxed` /// traits). @@ -2806,12 +2806,12 @@ pub trait Placer { fn make_place(self) -> Self::Place; } -/// Specialization of `Place` trait supporting `in (PLACE) EXPR`. +/// Specialization of `Place` trait supporting `PLACE <- EXPR`. #[unstable(feature = "placement_new_protocol", issue = "27779")] pub trait InPlace: Place { - /// `Owner` is the type of the end value of `in (PLACE) EXPR` + /// `Owner` is the type of the end value of `PLACE <- EXPR` /// - /// Note that when `in (PLACE) EXPR` is solely used for + /// Note that when `PLACE <- EXPR` is solely used for /// side-effecting an existing data-structure, /// e.g. `Vec::emplace_back`, then `Owner` need not carry any /// information at all (e.g. it can be the unit type `()` in that From fe791d78866941da4996e14b43706fead913b447 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 20 Jan 2017 18:44:36 -0700 Subject: [PATCH 2/7] Use libc errno --- src/libstd/sys/redox/os.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index 135e972bca401..9d459581dd40c 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -33,9 +33,16 @@ use vec; const TMPBUF_SZ: usize = 128; static ENV_LOCK: Mutex = Mutex::new(); +extern { + #[link_name = "__errno_location"] + fn errno_location() -> *mut i32; +} + /// Returns the platform-specific value of errno pub fn errno() -> i32 { - 0 + unsafe { + (*errno_location()) + } } /// Gets a detailed string description for the given error number. From 91a478ec3451f5e45f099218efb05a77bd632d86 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sun, 22 Jan 2017 22:35:27 -0500 Subject: [PATCH 3/7] Remove a FIXME in core/hash tests --- src/libcoretest/hash/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libcoretest/hash/mod.rs b/src/libcoretest/hash/mod.rs index 4ea42644ecdfd..0d12433813343 100644 --- a/src/libcoretest/hash/mod.rs +++ b/src/libcoretest/hash/mod.rs @@ -62,9 +62,8 @@ fn test_writer_hasher() { let s: &str = "a"; assert_eq!(hash(& s), 97 + 0xFF); - // FIXME (#18283) Enable test - //let s: Box = box "a"; - //assert_eq!(hasher.hash(& s), 97 + 0xFF); + let s: Box = String::from("a").into_boxed_str(); + assert_eq!(hash(& s), 97 + 0xFF); let cs: &[u8] = &[1, 2, 3]; assert_eq!(hash(& cs), 9); // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. From 4c5d1a4c22456de0d0e9dce98a5d6565d67d3471 Mon Sep 17 00:00:00 2001 From: king6cong Date: Tue, 24 Jan 2017 16:42:00 +0800 Subject: [PATCH 4/7] doc comment rewording --- src/librustc/hir/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index b631d67e47365..093b3346877d9 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1008,7 +1008,7 @@ pub enum QPath { /// /// UFCS source paths can desugar into this, with `Vec::new` turning into /// `::new`, and `T::X::Y::method` into `<<::X>::Y>::method`, - /// the `X` and `Y` nodes being each a `TyPath(QPath::TypeRelative(..))`. + /// the `X` and `Y` nodes each being a `TyPath(QPath::TypeRelative(..))`. TypeRelative(P, P) } From e7c0f747e3c322503ea26790586796e93eb7b067 Mon Sep 17 00:00:00 2001 From: king6cong Date: Tue, 24 Jan 2017 17:35:19 +0800 Subject: [PATCH 5/7] doc typo fix --- src/librustc/hir/intravisit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 7527d7fb318dd..92a46cec1ce73 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -154,7 +154,7 @@ pub trait Visitor<'v> : Sized { /// hashed separately. /// /// **If for some reason you want the nested behavior, but don't - /// have a `Map` are your disposal:** then you should override the + /// have a `Map` at your disposal:** then you should override the /// `visit_nested_XXX` methods, and override this method to /// `panic!()`. This way, if a new `visit_nested_XXX` variant is /// added in the future, we will see the panic in your code and From c8d1f322caa82b38e6b7d3e2eafb9c77c1978e01 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 Jan 2017 21:16:41 +0100 Subject: [PATCH 6/7] Add missing urls for array docs --- src/libstd/primitive_docs.rs | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index ce6ea2c1257fe..11197db98a396 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -272,7 +272,7 @@ mod prim_pointer { } /// Arrays of sizes from 0 to 32 (inclusive) implement the following traits if /// the element type allows it: /// -/// - [`Clone`][clone] (only if `T: Copy`) +/// - [`Clone`][clone] (only if `T: [Copy][copy]`) /// - [`Debug`][debug] /// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`) /// - [`PartialEq`][partialeq], [`PartialOrd`][partialord], [`Eq`][eq], [`Ord`][ord] @@ -287,8 +287,8 @@ mod prim_pointer { } /// entirely different types. As a stopgap, trait implementations are /// statically generated up to size 32. /// -/// Arrays of *any* size are [`Copy`][copy] if the element type is `Copy`. This -/// works because the `Copy` trait is specially known to the compiler. +/// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy]. This +/// works because the [`Copy`][copy] trait is specially known to the compiler. /// /// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on /// an array. Indeed, this provides most of the API for working with arrays. @@ -297,23 +297,6 @@ mod prim_pointer { } /// There is no way to move elements out of an array. See [`mem::replace`][replace] /// for an alternative. /// -/// [slice]: primitive.slice.html -/// [copy]: marker/trait.Copy.html -/// [clone]: clone/trait.Clone.html -/// [debug]: fmt/trait.Debug.html -/// [intoiterator]: iter/trait.IntoIterator.html -/// [partialeq]: cmp/trait.PartialEq.html -/// [partialord]: cmp/trait.PartialOrd.html -/// [eq]: cmp/trait.Eq.html -/// [ord]: cmp/trait.Ord.html -/// [hash]: hash/trait.Hash.html -/// [asref]: convert/trait.AsRef.html -/// [asmut]: convert/trait.AsMut.html -/// [borrow]: borrow/trait.Borrow.html -/// [borrowmut]: borrow/trait.BorrowMut.html -/// [default]: default/trait.Default.html -/// [replace]: mem/fn.replace.html -/// /// # Examples /// /// ``` @@ -347,13 +330,31 @@ mod prim_pointer { } /// ``` /// /// If the array has 32 or fewer elements (see above), you can also use the -/// array reference's `IntoIterator` implementation: +/// array reference's [`IntoIterator`] implementation: /// /// ``` /// # let array: [i32; 3] = [0; 3]; /// for x in &array { } /// ``` /// +/// [slice]: primitive.slice.html +/// [copy]: marker/trait.Copy.html +/// [clone]: clone/trait.Clone.html +/// [debug]: fmt/trait.Debug.html +/// [intoiterator]: iter/trait.IntoIterator.html +/// [partialeq]: cmp/trait.PartialEq.html +/// [partialord]: cmp/trait.PartialOrd.html +/// [eq]: cmp/trait.Eq.html +/// [ord]: cmp/trait.Ord.html +/// [hash]: hash/trait.Hash.html +/// [asref]: convert/trait.AsRef.html +/// [asmut]: convert/trait.AsMut.html +/// [borrow]: borrow/trait.Borrow.html +/// [borrowmut]: borrow/trait.BorrowMut.html +/// [default]: default/trait.Default.html +/// [replace]: mem/fn.replace.html +/// [`IntoIterator`]: iter/trait.IntoIterator.html +/// #[stable(feature = "rust1", since = "1.0.0")] mod prim_array { } From c4c86dd04ccf6e9a6ac9282ecb9bb42e13ea5dad Mon Sep 17 00:00:00 2001 From: Raphael Das Gupta Date: Tue, 24 Jan 2017 22:44:41 +0100 Subject: [PATCH 7/7] fix book: refer to `add_two` as "tested function" rather than "test function", which would be `it_works` --- src/doc/book/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/testing.md b/src/doc/book/testing.md index 96cec7295aa9d..940367b397100 100644 --- a/src/doc/book/testing.md +++ b/src/doc/book/testing.md @@ -384,7 +384,7 @@ currently trying to run the tests. This can save compile time, and also ensures that our tests are entirely left out of a normal build. The second change is the `use` declaration. Because we're in an inner module, -we need to bring our test function into scope. This can be annoying if you have +we need to bring the tested function into scope. This can be annoying if you have a large module, and so this is a common use of globs. Let's change our `src/lib.rs` to make use of it: