diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 4bbc180b226a5..2a5ad5e6c98a6 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1152,7 +1152,7 @@ declare_lint! { /// ```rust /// #![feature(box_syntax)] /// fn main() { - /// let a = (box [1,2,3]).len(); + /// let a = (box [1, 2, 3]).len(); /// } /// ``` /// diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 1d0d6980b7a89..fa82dce0ae2ed 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1719,7 +1719,7 @@ declare_lint! { /// /// impl MyIterator for T where T: Iterator { } /// - /// let x = vec![1,2,3]; + /// let x = vec![1, 2, 3]; /// let _ = x.iter().is_sorted(); /// ``` /// diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 6641ad33f92a6..a9e416875905c 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -1037,7 +1037,7 @@ impl BTreeMap { /// let mut count: BTreeMap<&str, usize> = BTreeMap::new(); /// /// // count the number of occurrences of letters in the vec - /// for x in vec!["a","b","a","c","a","b"] { + /// for x in vec!["a", "b", "a", "c", "a", "b"] { /// *count.entry(x).or_insert(0) += 1; /// } /// diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 1c183858e7a5e..85c809e0d188d 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1962,7 +1962,7 @@ impl VecDeque { /// ``` /// use std::collections::VecDeque; /// - /// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect(); + /// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect(); /// let buf2 = buf.split_off(1); /// assert_eq!(buf, [1]); /// assert_eq!(buf2, [2, 3]); @@ -2514,10 +2514,10 @@ impl VecDeque { /// (3, 1), (1, 2), (2, 3), (4, 5), (5, 8), (3, 13), /// (1, 21), (2, 34), (4, 55)].into(); /// - /// assert_eq!(deque.binary_search_by_key(&13, |&(a,b)| b), Ok(9)); - /// assert_eq!(deque.binary_search_by_key(&4, |&(a,b)| b), Err(7)); - /// assert_eq!(deque.binary_search_by_key(&100, |&(a,b)| b), Err(13)); - /// let r = deque.binary_search_by_key(&1, |&(a,b)| b); + /// assert_eq!(deque.binary_search_by_key(&13, |&(a, b)| b), Ok(9)); + /// assert_eq!(deque.binary_search_by_key(&4, |&(a, b)| b), Err(7)); + /// assert_eq!(deque.binary_search_by_key(&100, |&(a, b)| b), Err(13)); + /// let r = deque.binary_search_by_key(&1, |&(a, b)| b); /// assert!(matches!(r, Ok(1..=4))); /// ``` #[unstable(feature = "vecdeque_binary_search", issue = "78021")] diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 392c16546efb0..2225bf63e3cdc 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1041,7 +1041,7 @@ impl Vec { /// } /// x.set_len(size); /// } - /// assert_eq!(&*x, &[0,1,2,3]); + /// assert_eq!(&*x, &[0, 1, 2, 3]); /// ``` #[stable(feature = "vec_as_ptr", since = "1.37.0")] #[inline] @@ -1594,7 +1594,7 @@ impl Vec { /// # Examples /// /// ``` - /// let mut vec = vec![1,2,3]; + /// let mut vec = vec![1, 2, 3]; /// let vec2 = vec.split_off(1); /// assert_eq!(vec, [1]); /// assert_eq!(vec2, [2, 3]); diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 660b7db70be92..94ac16954a730 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -392,7 +392,7 @@ impl MaybeUninit { /// use std::mem::MaybeUninit; /// /// let mut x = MaybeUninit::>::uninit(); - /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } + /// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); } /// // Create a reference into the `MaybeUninit`. This is okay because we initialized it. /// let x_vec = unsafe { &*x.as_ptr() }; /// assert_eq!(x_vec.len(), 3); @@ -429,7 +429,7 @@ impl MaybeUninit { /// use std::mem::MaybeUninit; /// /// let mut x = MaybeUninit::>::uninit(); - /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } + /// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); } /// // Create a reference into the `MaybeUninit>`. /// // This is okay because we initialized it. /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; @@ -565,7 +565,7 @@ impl MaybeUninit { /// use std::mem::MaybeUninit; /// /// let mut x = MaybeUninit::>>::uninit(); - /// x.write(Some(vec![0,1,2])); + /// x.write(Some(vec![0, 1, 2])); /// let x1 = unsafe { x.assume_init_read() }; /// let x2 = unsafe { x.assume_init_read() }; /// // We now created two copies of the same vector, leading to a double-free ⚠️ when diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 3c2ada5761233..a8dea4e9b4ea8 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -79,7 +79,7 @@ pub trait Index { /// each can be indexed mutably and immutably. /// /// ``` -/// use std::ops::{Index,IndexMut}; +/// use std::ops::{Index, IndexMut}; /// /// #[derive(Debug)] /// enum Side { diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index bedd9dfa1fec5..107563840d0f5 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1958,10 +1958,10 @@ impl [T] { /// (1, 2), (2, 3), (4, 5), (5, 8), (3, 13), /// (1, 21), (2, 34), (4, 55)]; /// - /// assert_eq!(s.binary_search_by_key(&13, |&(a,b)| b), Ok(9)); - /// assert_eq!(s.binary_search_by_key(&4, |&(a,b)| b), Err(7)); - /// assert_eq!(s.binary_search_by_key(&100, |&(a,b)| b), Err(13)); - /// let r = s.binary_search_by_key(&1, |&(a,b)| b); + /// assert_eq!(s.binary_search_by_key(&13, |&(a, b)| b), Ok(9)); + /// assert_eq!(s.binary_search_by_key(&4, |&(a, b)| b), Err(7)); + /// assert_eq!(s.binary_search_by_key(&100, |&(a, b)| b), Err(13)); + /// let r = s.binary_search_by_key(&1, |&(a, b)| b); /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]