From b91acc9f2a9e80dfa04af62d20bf69d302a1a5e2 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Thu, 14 Jul 2016 05:29:50 +0900 Subject: [PATCH 1/7] Remove extra newlines in MIR dump --- src/librustc_mir/pretty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/pretty.rs b/src/librustc_mir/pretty.rs index 515620d4253..c9ca1a963a4 100644 --- a/src/librustc_mir/pretty.rs +++ b/src/librustc_mir/pretty.rs @@ -195,7 +195,7 @@ fn write_basic_block(tcx: TyCtxt, ALIGN, comment(tcx, data.terminator().source_info))?; - writeln!(w, "{}}}\n", INDENT) + writeln!(w, "{}}}", INDENT) } fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String { From e2f5961f35a012f64bbb054d9eadeed608b82983 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 16 Jul 2016 11:20:17 -0400 Subject: [PATCH 2/7] Partial rewrite/expansion of `Vec::truncate` documentation. --- src/libcollections/vec.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index da56b21cf0c..96614423389 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -479,18 +479,45 @@ impl Vec { } } - /// Shorten a vector to be `len` elements long, dropping excess elements. + /// Shortens the vector, keeping the first `len` elements and dropping + /// the rest. /// /// If `len` is greater than the vector's current length, this has no /// effect. /// + /// The [`drain`] method can emulate `truncate`, but causes the excess + /// elements to be returned instead of dropped. + /// /// # Examples /// + /// Truncating a five element vector to two elements: + /// /// ``` /// let mut vec = vec![1, 2, 3, 4, 5]; /// vec.truncate(2); /// assert_eq!(vec, [1, 2]); /// ``` + /// + /// No truncation occurs when `len` is greater than the vector's current + /// length: + /// + /// ``` + /// let mut vec = vec![1, 2, 3]; + /// vec.truncate(8); + /// assert_eq!(vec, [1, 2, 3]); + /// ``` + /// + /// Truncating when `len == 0` is equivalent to calling the [`clear`] + /// method. + /// + /// ``` + /// let mut vec = vec![1, 2, 3]; + /// vec.truncate(0); + /// assert_eq!(vec, []); + /// ``` + /// + /// [`clear`]: #method.clear + /// [`drain`]: #method.drain #[stable(feature = "rust1", since = "1.0.0")] pub fn truncate(&mut self, len: usize) { unsafe { From b2f5b5a812b0b9a8d4e5e0dec16ba44ef16d3e55 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 16 Jul 2016 21:42:11 -0400 Subject: [PATCH 3/7] Indicate where `std::slice` structs originate from. --- src/libcore/slice.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 4f11cac4eb2..d8a11581c3b 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -902,6 +902,8 @@ macro_rules! make_mut_slice { /// Immutable slice iterator /// +/// This struct is created by the [`iter`] method on [slices]. +/// /// # Examples /// /// Basic usage: @@ -915,6 +917,9 @@ macro_rules! make_mut_slice { /// println!("{}", element); /// } /// ``` +/// +/// [`iter`]: ../../std/primitive.slice.html#method.iter +/// [slices]: ../../std/primitive.slice.html #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { ptr: *const T, @@ -993,6 +998,8 @@ impl<'a, T> Clone for Iter<'a, T> { /// Mutable slice iterator. /// +/// This struct is created by the [`iter_mut`] method on [slices]. +/// /// # Examples /// /// Basic usage: @@ -1010,6 +1017,9 @@ impl<'a, T> Clone for Iter<'a, T> { /// // We now have "[2, 3, 4]": /// println!("{:?}", slice); /// ``` +/// +/// [`iter_mut`]: ../../std/primitive.slice.html#method.iter_mut +/// [slices]: ../../std/primitive.slice.html #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { ptr: *mut T, From 4e5e36fb79e1cffc6f7c3a9670df222060bb0e4b Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Sun, 17 Jul 2016 20:57:54 +0200 Subject: [PATCH 4/7] test: disable more stdcall tests for ARM arches. temp workaround for #24958 --- src/test/debuginfo/type-names.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index a74369ed3c3..2419625cbd3 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -11,6 +11,8 @@ // ignore-tidy-linelength // ignore-lldb // ignore-android: FIXME(#24958) +// ignore-arm: FIXME(#24958) +// ignore-aarch64: FIXME(#24958) // compile-flags:-g From 8aaf0f894bfbbc8e1135e42ce7cb9258d55f41cc Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Sun, 17 Jul 2016 21:00:24 +0200 Subject: [PATCH 5/7] doc/book: fix tests for non-x86 architectures, such as aarch64 `rustdoc --test` gets confused when "main" exists for some architectures but not others. --- src/doc/book/inline-assembly.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/doc/book/inline-assembly.md b/src/doc/book/inline-assembly.md index a8340d9d31e..62e196a7ccd 100644 --- a/src/doc/book/inline-assembly.md +++ b/src/doc/book/inline-assembly.md @@ -60,6 +60,8 @@ asm!("xor %eax, %eax" : "eax" ); # } } +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +# fn main() {} ``` Whitespace also doesn't matter: @@ -70,6 +72,8 @@ Whitespace also doesn't matter: # fn main() { unsafe { asm!("xor %eax, %eax" ::: "eax"); # } } +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +# fn main() {} ``` ## Operands @@ -129,6 +133,8 @@ stay valid. // Put the value 0x200 in eax asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax"); # } } +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +# fn main() {} ``` Input and output registers need not be listed since that information @@ -164,6 +170,8 @@ unsafe { } println!("eax is currently {}", result); # } +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +# fn main() {} ``` ## More Information From f6be6aa92acd34d3a8815e29bb09b7ec2a72fedc Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 17 Jul 2016 10:52:59 -0400 Subject: [PATCH 6/7] Document from_raw_parts involves ownership transfer --- src/libcollections/string.rs | 6 ++++++ src/libcollections/vec.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index eedf4c2c11f..8ba5c6ffbf2 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -701,6 +701,12 @@ impl String { /// Violating these may cause problems like corrupting the allocator's /// internal datastructures. /// + /// The ownership of `ptr` is effectively transferred to the + /// `String` which may then deallocate, reallocate or change the + /// contents of memory pointed to by the pointer at will. Ensure + /// that nothing else uses the pointer after calling this + /// function. + /// /// # Examples /// /// Basic usage: diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index da56b21cf0c..98b5c4663cd 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -348,6 +348,12 @@ impl Vec { /// Violating these may cause problems like corrupting the allocator's /// internal datastructures. /// + /// The ownership of `ptr` is effectively transferred to the + /// `Vec` which may then deallocate, reallocate or change the + /// contents of memory pointed to by the pointer at will. Ensure + /// that nothing else uses the pointer after calling this + /// function. + /// /// # Examples /// /// ``` From 661187a95eb9b00a4a120de7d22ee28706574656 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 17 Jul 2016 10:55:00 -0400 Subject: [PATCH 7/7] Remove extraneous words --- src/libcollections/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 98b5c4663cd..3c221f0fea0 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -342,7 +342,7 @@ impl Vec { /// /// * `ptr` needs to have been previously allocated via `String`/`Vec` /// (at least, it's highly likely to be incorrect if it wasn't). - /// * `length` needs to be the length that less than or equal to `capacity`. + /// * `length` needs to be less than or equal to `capacity`. /// * `capacity` needs to be the capacity that the pointer was allocated with. /// /// Violating these may cause problems like corrupting the allocator's