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 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 7a3c9bc3bb2..518b94b5031 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -342,12 +342,18 @@ 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 /// 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 /// /// ``` @@ -479,18 +485,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 { 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, 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 { 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