From 7230a15c32d01e1653d98c39ddd79097a59b550c Mon Sep 17 00:00:00 2001
From: est31 <MTest31@outlook.com>
Date: Sat, 28 May 2022 23:22:07 +0200
Subject: [PATCH 1/8] Use Box::new() instead of box syntax in alloc tests

---
 library/alloc/src/alloc/tests.rs              |  2 +-
 .../src/collections/binary_heap/tests.rs      | 12 +++++-----
 library/alloc/src/collections/linked_list.rs  |  4 ++--
 .../src/collections/linked_list/tests.rs      | 22 +++++++++----------
 library/alloc/src/rc.rs                       |  7 +++---
 library/alloc/src/rc/tests.rs                 | 12 +++++-----
 library/alloc/src/sync.rs                     |  8 +++----
 library/alloc/src/sync/tests.rs               | 10 ++++-----
 library/alloc/tests/slice.rs                  | 14 ++++++------
 library/alloc/tests/vec.rs                    | 10 ++++-----
 10 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/library/alloc/src/alloc/tests.rs b/library/alloc/src/alloc/tests.rs
index 94e05fa448f86..7d560964d85be 100644
--- a/library/alloc/src/alloc/tests.rs
+++ b/library/alloc/src/alloc/tests.rs
@@ -25,6 +25,6 @@ fn allocate_zeroed() {
 #[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
 fn alloc_owned_small(b: &mut Bencher) {
     b.iter(|| {
-        let _: Box<_> = box 10;
+        let _: Box<_> = Box::new(10);
     })
 }
diff --git a/library/alloc/src/collections/binary_heap/tests.rs b/library/alloc/src/collections/binary_heap/tests.rs
index 7c758dbb3ab8a..5a05215aeeddf 100644
--- a/library/alloc/src/collections/binary_heap/tests.rs
+++ b/library/alloc/src/collections/binary_heap/tests.rs
@@ -183,22 +183,22 @@ fn test_push() {
 
 #[test]
 fn test_push_unique() {
-    let mut heap = BinaryHeap::<Box<_>>::from(vec![box 2, box 4, box 9]);
+    let mut heap = BinaryHeap::<Box<_>>::from(vec![Box::new(2), Box::new(4), Box::new(9)]);
     assert_eq!(heap.len(), 3);
     assert!(**heap.peek().unwrap() == 9);
-    heap.push(box 11);
+    heap.push(Box::new(11));
     assert_eq!(heap.len(), 4);
     assert!(**heap.peek().unwrap() == 11);
-    heap.push(box 5);
+    heap.push(Box::new(5));
     assert_eq!(heap.len(), 5);
     assert!(**heap.peek().unwrap() == 11);
-    heap.push(box 27);
+    heap.push(Box::new(27));
     assert_eq!(heap.len(), 6);
     assert!(**heap.peek().unwrap() == 27);
-    heap.push(box 3);
+    heap.push(Box::new(3));
     assert_eq!(heap.len(), 7);
     assert!(**heap.peek().unwrap() == 27);
-    heap.push(box 103);
+    heap.push(Box::new(103));
     assert_eq!(heap.len(), 8);
     assert!(**heap.peek().unwrap() == 103);
 }
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs
index 67dc4f30f3179..e21c8aa3bd536 100644
--- a/library/alloc/src/collections/linked_list.rs
+++ b/library/alloc/src/collections/linked_list.rs
@@ -791,7 +791,7 @@ impl<T> LinkedList<T> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn push_front(&mut self, elt: T) {
-        self.push_front_node(box Node::new(elt));
+        self.push_front_node(Box::new(Node::new(elt)));
     }
 
     /// Removes the first element and returns it, or `None` if the list is
@@ -834,7 +834,7 @@ impl<T> LinkedList<T> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn push_back(&mut self, elt: T) {
-        self.push_back_node(box Node::new(elt));
+        self.push_back_node(Box::new(Node::new(elt)));
     }
 
     /// Removes the last element from a list and returns it, or `None` if
diff --git a/library/alloc/src/collections/linked_list/tests.rs b/library/alloc/src/collections/linked_list/tests.rs
index 38c702aa387bd..f8fbfa1bfbc87 100644
--- a/library/alloc/src/collections/linked_list/tests.rs
+++ b/library/alloc/src/collections/linked_list/tests.rs
@@ -12,20 +12,20 @@ fn test_basic() {
     assert_eq!(m.pop_front(), None);
     assert_eq!(m.pop_back(), None);
     assert_eq!(m.pop_front(), None);
-    m.push_front(box 1);
-    assert_eq!(m.pop_front(), Some(box 1));
-    m.push_back(box 2);
-    m.push_back(box 3);
+    m.push_front(Box::new(1));
+    assert_eq!(m.pop_front(), Some(Box::new(1)));
+    m.push_back(Box::new(2));
+    m.push_back(Box::new(3));
     assert_eq!(m.len(), 2);
-    assert_eq!(m.pop_front(), Some(box 2));
-    assert_eq!(m.pop_front(), Some(box 3));
+    assert_eq!(m.pop_front(), Some(Box::new(2)));
+    assert_eq!(m.pop_front(), Some(Box::new(3)));
     assert_eq!(m.len(), 0);
     assert_eq!(m.pop_front(), None);
-    m.push_back(box 1);
-    m.push_back(box 3);
-    m.push_back(box 5);
-    m.push_back(box 7);
-    assert_eq!(m.pop_front(), Some(box 1));
+    m.push_back(Box::new(1));
+    m.push_back(Box::new(3));
+    m.push_back(Box::new(5));
+    m.push_back(Box::new(7));
+    assert_eq!(m.pop_front(), Some(Box::new(1)));
 
     let mut n = LinkedList::new();
     n.push_front(2);
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 5295745647365..2b3736019ba40 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -369,7 +369,8 @@ impl<T> Rc<T> {
         // if the weak pointer is stored inside the strong one.
         unsafe {
             Self::from_inner(
-                Box::leak(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value }).into(),
+                Box::leak(Box::new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value }))
+                    .into(),
             )
         }
     }
@@ -433,11 +434,11 @@ impl<T> Rc<T> {
     {
         // Construct the inner in the "uninitialized" state with a single
         // weak reference.
-        let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
+        let uninit_ptr: NonNull<_> = Box::leak(Box::new(RcBox {
             strong: Cell::new(0),
             weak: Cell::new(1),
             value: mem::MaybeUninit::<T>::uninit(),
-        })
+        }))
         .into();
 
         let init_ptr: NonNull<RcBox<T>> = uninit_ptr.cast();
diff --git a/library/alloc/src/rc/tests.rs b/library/alloc/src/rc/tests.rs
index d7c28f8063337..32433cfbdcff6 100644
--- a/library/alloc/src/rc/tests.rs
+++ b/library/alloc/src/rc/tests.rs
@@ -32,7 +32,7 @@ fn test_simple_clone() {
 
 #[test]
 fn test_destructor() {
-    let x: Rc<Box<_>> = Rc::new(box 5);
+    let x: Rc<Box<_>> = Rc::new(Box::new(5));
     assert_eq!(**x, 5);
 }
 
@@ -153,7 +153,7 @@ fn try_unwrap() {
 
 #[test]
 fn into_from_raw() {
-    let x = Rc::new(box "hello");
+    let x = Rc::new(Box::new("hello"));
     let y = x.clone();
 
     let x_ptr = Rc::into_raw(x);
@@ -192,7 +192,7 @@ fn test_into_from_raw_unsized() {
 
 #[test]
 fn into_from_weak_raw() {
-    let x = Rc::new(box "hello");
+    let x = Rc::new(Box::new("hello"));
     let y = Rc::downgrade(&x);
 
     let y_ptr = Weak::into_raw(y);
@@ -409,7 +409,7 @@ fn test_clone_from_slice_panic() {
 
 #[test]
 fn test_from_box() {
-    let b: Box<u32> = box 123;
+    let b: Box<u32> = Box::new(123);
     let r: Rc<u32> = Rc::from(b);
 
     assert_eq!(*r, 123);
@@ -438,7 +438,7 @@ fn test_from_box_trait() {
     use std::fmt::Display;
     use std::string::ToString;
 
-    let b: Box<dyn Display> = box 123;
+    let b: Box<dyn Display> = Box::new(123);
     let r: Rc<dyn Display> = Rc::from(b);
 
     assert_eq!(r.to_string(), "123");
@@ -448,7 +448,7 @@ fn test_from_box_trait() {
 fn test_from_box_trait_zero_sized() {
     use std::fmt::Debug;
 
-    let b: Box<dyn Debug> = box ();
+    let b: Box<dyn Debug> = Box::new(());
     let r: Rc<dyn Debug> = Rc::from(b);
 
     assert_eq!(format!("{r:?}"), "()");
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index 06aecd9cc1efd..d5ed3fd18c3b8 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -343,11 +343,11 @@ impl<T> Arc<T> {
     pub fn new(data: T) -> Arc<T> {
         // Start the weak pointer count as 1 which is the weak pointer that's
         // held by all the strong pointers (kinda), see std/rc.rs for more info
-        let x: Box<_> = box ArcInner {
+        let x: Box<_> = Box::new(ArcInner {
             strong: atomic::AtomicUsize::new(1),
             weak: atomic::AtomicUsize::new(1),
             data,
-        };
+        });
         unsafe { Self::from_inner(Box::leak(x).into()) }
     }
 
@@ -411,11 +411,11 @@ impl<T> Arc<T> {
     {
         // Construct the inner in the "uninitialized" state with a single
         // weak reference.
-        let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {
+        let uninit_ptr: NonNull<_> = Box::leak(Box::new(ArcInner {
             strong: atomic::AtomicUsize::new(0),
             weak: atomic::AtomicUsize::new(1),
             data: mem::MaybeUninit::<T>::uninit(),
-        })
+        }))
         .into();
         let init_ptr: NonNull<ArcInner<T>> = uninit_ptr.cast();
 
diff --git a/library/alloc/src/sync/tests.rs b/library/alloc/src/sync/tests.rs
index 452a88773018c..202d0e7f02057 100644
--- a/library/alloc/src/sync/tests.rs
+++ b/library/alloc/src/sync/tests.rs
@@ -103,7 +103,7 @@ fn try_unwrap() {
 
 #[test]
 fn into_from_raw() {
-    let x = Arc::new(box "hello");
+    let x = Arc::new(Box::new("hello"));
     let y = x.clone();
 
     let x_ptr = Arc::into_raw(x);
@@ -142,7 +142,7 @@ fn test_into_from_raw_unsized() {
 
 #[test]
 fn into_from_weak_raw() {
-    let x = Arc::new(box "hello");
+    let x = Arc::new(Box::new("hello"));
     let y = Arc::downgrade(&x);
 
     let y_ptr = Weak::into_raw(y);
@@ -467,7 +467,7 @@ fn test_clone_from_slice_panic() {
 
 #[test]
 fn test_from_box() {
-    let b: Box<u32> = box 123;
+    let b: Box<u32> = Box::new(123);
     let r: Arc<u32> = Arc::from(b);
 
     assert_eq!(*r, 123);
@@ -496,7 +496,7 @@ fn test_from_box_trait() {
     use std::fmt::Display;
     use std::string::ToString;
 
-    let b: Box<dyn Display> = box 123;
+    let b: Box<dyn Display> = Box::new(123);
     let r: Arc<dyn Display> = Arc::from(b);
 
     assert_eq!(r.to_string(), "123");
@@ -506,7 +506,7 @@ fn test_from_box_trait() {
 fn test_from_box_trait_zero_sized() {
     use std::fmt::Debug;
 
-    let b: Box<dyn Debug> = box ();
+    let b: Box<dyn Debug> = Box::new(());
     let r: Arc<dyn Debug> = Arc::from(b);
 
     assert_eq!(format!("{r:?}"), "()");
diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs
index b027a25a146bc..21f894343be09 100644
--- a/library/alloc/tests/slice.rs
+++ b/library/alloc/tests/slice.rs
@@ -268,9 +268,9 @@ fn test_swap_remove_fail() {
 fn test_swap_remove_noncopyable() {
     // Tests that we don't accidentally run destructors twice.
     let mut v: Vec<Box<_>> = Vec::new();
-    v.push(box 0);
-    v.push(box 0);
-    v.push(box 0);
+    v.push(Box::new(0));
+    v.push(Box::new(0));
+    v.push(Box::new(0));
     let mut _e = v.swap_remove(0);
     assert_eq!(v.len(), 2);
     _e = v.swap_remove(1);
@@ -296,7 +296,7 @@ fn test_push() {
 
 #[test]
 fn test_truncate() {
-    let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4];
+    let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)];
     v.truncate(1);
     let v = v;
     assert_eq!(v.len(), 1);
@@ -306,7 +306,7 @@ fn test_truncate() {
 
 #[test]
 fn test_clear() {
-    let mut v: Vec<Box<_>> = vec![box 6, box 5, box 4];
+    let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)];
     v.clear();
     assert_eq!(v.len(), 0);
     // If the unsafe block didn't drop things properly, we blow up here.
@@ -1516,14 +1516,14 @@ fn test_mut_last() {
 
 #[test]
 fn test_to_vec() {
-    let xs: Box<_> = box [1, 2, 3];
+    let xs: Box<_> = Box::new([1, 2, 3]);
     let ys = xs.to_vec();
     assert_eq!(ys, [1, 2, 3]);
 }
 
 #[test]
 fn test_in_place_iterator_specialization() {
-    let src: Box<[usize]> = box [1, 2, 3];
+    let src: Box<[usize]> = Box::new([1, 2, 3]);
     let src_ptr = src.as_ptr();
     let sink: Box<_> = src.into_vec().into_iter().map(std::convert::identity).collect();
     let sink_ptr = sink.as_ptr();
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index bc1397146dda9..cc768c73c0e03 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -266,8 +266,8 @@ fn test_clone() {
 #[test]
 fn test_clone_from() {
     let mut v = vec![];
-    let three: Vec<Box<_>> = vec![box 1, box 2, box 3];
-    let two: Vec<Box<_>> = vec![box 4, box 5];
+    let three: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(3)];
+    let two: Vec<Box<_>> = vec![Box::new(4), Box::new(5)];
     // zero, long
     v.clone_from(&three);
     assert_eq!(v, three);
@@ -407,11 +407,11 @@ fn test_dedup_by() {
 
 #[test]
 fn test_dedup_unique() {
-    let mut v0: Vec<Box<_>> = vec![box 1, box 1, box 2, box 3];
+    let mut v0: Vec<Box<_>> = vec![Box::new(1), Box::new(1), Box::new(2), Box::new(3)];
     v0.dedup();
-    let mut v1: Vec<Box<_>> = vec![box 1, box 2, box 2, box 3];
+    let mut v1: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(2), Box::new(3)];
     v1.dedup();
-    let mut v2: Vec<Box<_>> = vec![box 1, box 2, box 3, box 3];
+    let mut v2: Vec<Box<_>> = vec![Box::new(1), Box::new(2), Box::new(3), Box::new(3)];
     v2.dedup();
     // If the boxed pointers were leaked or otherwise misused, valgrind
     // and/or rt should raise errors.

From d75c60f9a37c9b1810ddcdf19216da76319bdf04 Mon Sep 17 00:00:00 2001
From: est31 <MTest31@outlook.com>
Date: Sun, 29 May 2022 00:25:32 +0200
Subject: [PATCH 2/8] Use Box::new() instead of box syntax in std tests

---
 library/std/src/io/error/tests.rs             |  6 +++---
 library/std/src/sync/mpsc/mpsc_queue/tests.rs |  4 ++--
 library/std/src/sync/mpsc/spsc_queue/tests.rs |  4 ++--
 library/std/src/sync/mpsc/sync_tests.rs       | 12 ++++++------
 library/std/src/sync/mpsc/tests.rs            | 14 +++++++-------
 library/std/src/thread/tests.rs               |  4 ++--
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs
index 6fd15fa80488b..8d7877bcad35d 100644
--- a/library/std/src/io/error/tests.rs
+++ b/library/std/src/io/error/tests.rs
@@ -17,10 +17,10 @@ fn test_debug_error() {
     let msg = error_string(code);
     let kind = decode_error_kind(code);
     let err = Error {
-        repr: Repr::new_custom(box Custom {
+        repr: Repr::new_custom(Box::new(Custom {
             kind: ErrorKind::InvalidInput,
-            error: box Error { repr: super::Repr::new_os(code) },
-        }),
+            error: Box::new(Error { repr: super::Repr::new_os(code) }),
+        })),
     };
     let expected = format!(
         "Custom {{ \
diff --git a/library/std/src/sync/mpsc/mpsc_queue/tests.rs b/library/std/src/sync/mpsc/mpsc_queue/tests.rs
index 348b83424b013..9f4f31ed05145 100644
--- a/library/std/src/sync/mpsc/mpsc_queue/tests.rs
+++ b/library/std/src/sync/mpsc/mpsc_queue/tests.rs
@@ -6,8 +6,8 @@ use crate::thread;
 #[test]
 fn test_full() {
     let q: Queue<Box<_>> = Queue::new();
-    q.push(box 1);
-    q.push(box 2);
+    q.push(Box::new(1));
+    q.push(Box::new(2));
 }
 
 #[test]
diff --git a/library/std/src/sync/mpsc/spsc_queue/tests.rs b/library/std/src/sync/mpsc/spsc_queue/tests.rs
index e4fd15cbbdef3..467ef3dbdcbbd 100644
--- a/library/std/src/sync/mpsc/spsc_queue/tests.rs
+++ b/library/std/src/sync/mpsc/spsc_queue/tests.rs
@@ -47,8 +47,8 @@ fn peek() {
 fn drop_full() {
     unsafe {
         let q: Queue<Box<_>> = Queue::with_additions(0, (), ());
-        q.push(box 1);
-        q.push(box 2);
+        q.push(Box::new(1));
+        q.push(Box::new(2));
     }
 }
 
diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs
index 0052a38f7bb75..e58649bab6e42 100644
--- a/library/std/src/sync/mpsc/sync_tests.rs
+++ b/library/std/src/sync/mpsc/sync_tests.rs
@@ -20,7 +20,7 @@ fn smoke() {
 #[test]
 fn drop_full() {
     let (tx, _rx) = sync_channel::<Box<isize>>(1);
-    tx.send(box 1).unwrap();
+    tx.send(Box::new(1)).unwrap();
 }
 
 #[test]
@@ -238,7 +238,7 @@ fn oneshot_single_thread_send_port_close() {
     // Testing that the sender cleans up the payload if receiver is closed
     let (tx, rx) = sync_channel::<Box<i32>>(0);
     drop(rx);
-    assert!(tx.send(box 0).is_err());
+    assert!(tx.send(Box::new(0)).is_err());
 }
 
 #[test]
@@ -257,7 +257,7 @@ fn oneshot_single_thread_recv_chan_close() {
 #[test]
 fn oneshot_single_thread_send_then_recv() {
     let (tx, rx) = sync_channel::<Box<i32>>(1);
-    tx.send(box 10).unwrap();
+    tx.send(Box::new(10)).unwrap();
     assert!(*rx.recv().unwrap() == 10);
 }
 
@@ -333,7 +333,7 @@ fn oneshot_multi_task_recv_then_send() {
         assert!(*rx.recv().unwrap() == 10);
     });
 
-    tx.send(box 10).unwrap();
+    tx.send(Box::new(10)).unwrap();
 }
 
 #[test]
@@ -398,7 +398,7 @@ fn oneshot_multi_thread_send_recv_stress() {
     for _ in 0..stress_factor() {
         let (tx, rx) = sync_channel::<Box<i32>>(0);
         let _t = thread::spawn(move || {
-            tx.send(box 10).unwrap();
+            tx.send(Box::new(10)).unwrap();
         });
         assert!(*rx.recv().unwrap() == 10);
     }
@@ -418,7 +418,7 @@ fn stream_send_recv_stress() {
             }
 
             thread::spawn(move || {
-                tx.send(box i).unwrap();
+                tx.send(Box::new(i)).unwrap();
                 send(tx, i + 1);
             });
         }
diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs
index 184ce193cbed9..4deb3e5961577 100644
--- a/library/std/src/sync/mpsc/tests.rs
+++ b/library/std/src/sync/mpsc/tests.rs
@@ -20,7 +20,7 @@ fn smoke() {
 #[test]
 fn drop_full() {
     let (tx, _rx) = channel::<Box<isize>>();
-    tx.send(box 1).unwrap();
+    tx.send(Box::new(1)).unwrap();
 }
 
 #[test]
@@ -28,7 +28,7 @@ fn drop_full_shared() {
     let (tx, _rx) = channel::<Box<isize>>();
     drop(tx.clone());
     drop(tx.clone());
-    tx.send(box 1).unwrap();
+    tx.send(Box::new(1)).unwrap();
 }
 
 #[test]
@@ -229,7 +229,7 @@ fn oneshot_single_thread_send_port_close() {
     // Testing that the sender cleans up the payload if receiver is closed
     let (tx, rx) = channel::<Box<i32>>();
     drop(rx);
-    assert!(tx.send(box 0).is_err());
+    assert!(tx.send(Box::new(0)).is_err());
 }
 
 #[test]
@@ -248,7 +248,7 @@ fn oneshot_single_thread_recv_chan_close() {
 #[test]
 fn oneshot_single_thread_send_then_recv() {
     let (tx, rx) = channel::<Box<i32>>();
-    tx.send(box 10).unwrap();
+    tx.send(Box::new(10)).unwrap();
     assert!(*rx.recv().unwrap() == 10);
 }
 
@@ -309,7 +309,7 @@ fn oneshot_multi_task_recv_then_send() {
         assert!(*rx.recv().unwrap() == 10);
     });
 
-    tx.send(box 10).unwrap();
+    tx.send(Box::new(10)).unwrap();
 }
 
 #[test]
@@ -374,7 +374,7 @@ fn oneshot_multi_thread_send_recv_stress() {
     for _ in 0..stress_factor() {
         let (tx, rx) = channel::<Box<isize>>();
         let _t = thread::spawn(move || {
-            tx.send(box 10).unwrap();
+            tx.send(Box::new(10)).unwrap();
         });
         assert!(*rx.recv().unwrap() == 10);
     }
@@ -394,7 +394,7 @@ fn stream_send_recv_stress() {
             }
 
             thread::spawn(move || {
-                tx.send(box i).unwrap();
+                tx.send(Box::new(i)).unwrap();
                 send(tx, i + 1);
             });
         }
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
index 7386fe1c442ab..5b8309cf5d273 100644
--- a/library/std/src/thread/tests.rs
+++ b/library/std/src/thread/tests.rs
@@ -127,7 +127,7 @@ where
 {
     let (tx, rx) = channel();
 
-    let x: Box<_> = box 1;
+    let x: Box<_> = Box::new(1);
     let x_in_parent = (&*x) as *const i32 as usize;
 
     spawnfn(Box::new(move || {
@@ -219,7 +219,7 @@ fn test_try_panic_any_message_owned_str() {
 #[test]
 fn test_try_panic_any_message_any() {
     match thread::spawn(move || {
-        panic_any(box 413u16 as Box<dyn Any + Send>);
+        panic_any(Box::new(413u16) as Box<dyn Any + Send>);
     })
     .join()
     {

From cdb8e64bc78400f9366db3b556bb01f470855f55 Mon Sep 17 00:00:00 2001
From: est31 <MTest31@outlook.com>
Date: Sun, 29 May 2022 00:40:47 +0200
Subject: [PATCH 3/8] Use Box::new() instead of box syntax in core tests

---
 library/core/tests/any.rs                      | 9 ++++++---
 library/core/tests/clone.rs                    | 4 ++--
 library/core/tests/iter/traits/double_ended.rs | 3 ++-
 library/core/tests/lib.rs                      | 1 -
 library/core/tests/option.rs                   | 4 ++--
 library/core/tests/result.rs                   | 2 +-
 6 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs
index eccddcbbf59fe..0dffd137565b3 100644
--- a/library/core/tests/any.rs
+++ b/library/core/tests/any.rs
@@ -24,8 +24,11 @@ fn any_referenced() {
 
 #[test]
 fn any_owning() {
-    let (a, b, c) =
-        (box 5_usize as Box<dyn Any>, box TEST as Box<dyn Any>, box Test as Box<dyn Any>);
+    let (a, b, c) = (
+        Box::new(5_usize) as Box<dyn Any>,
+        Box::new(TEST) as Box<dyn Any>,
+        Box::new(Test) as Box<dyn Any>,
+    );
 
     assert!(a.is::<usize>());
     assert!(!b.is::<usize>());
@@ -58,7 +61,7 @@ fn any_downcast_ref() {
 #[test]
 fn any_downcast_mut() {
     let mut a = 5_usize;
-    let mut b: Box<_> = box 7_usize;
+    let mut b: Box<_> = Box::new(7_usize);
 
     let a_r = &mut a as &mut dyn Any;
     let tmp: &mut usize = &mut *b;
diff --git a/library/core/tests/clone.rs b/library/core/tests/clone.rs
index c97a87aebce41..33ca9f2c6a3a1 100644
--- a/library/core/tests/clone.rs
+++ b/library/core/tests/clone.rs
@@ -8,8 +8,8 @@ fn test_borrowed_clone() {
 
 #[test]
 fn test_clone_from() {
-    let a = box 5;
-    let mut b = box 10;
+    let a = Box::new(5);
+    let mut b = Box::new(10);
     b.clone_from(&a);
     assert_eq!(*b, 5);
 }
diff --git a/library/core/tests/iter/traits/double_ended.rs b/library/core/tests/iter/traits/double_ended.rs
index 947d19d3dfed0..00ef4a6e6a987 100644
--- a/library/core/tests/iter/traits/double_ended.rs
+++ b/library/core/tests/iter/traits/double_ended.rs
@@ -78,7 +78,8 @@ fn test_rev_rposition() {
 #[test]
 #[should_panic]
 fn test_rposition_panic() {
-    let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), (box 0, box 0), (box 0, box 0)];
+    let u = (Box::new(0), Box::new(0));
+    let v: [(Box<_>, Box<_>); 4] = [u.clone(), u.clone(), u.clone(), u];
     let mut i = 0;
     v.iter().rposition(|_elt| {
         if i == 2 {
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 9ea374e1045a5..7e9d7d2710180 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -3,7 +3,6 @@
 #![feature(array_methods)]
 #![feature(array_windows)]
 #![feature(bench_black_box)]
-#![feature(box_syntax)]
 #![feature(cell_update)]
 #![feature(const_assume)]
 #![feature(const_black_box)]
diff --git a/library/core/tests/option.rs b/library/core/tests/option.rs
index da692461261fc..9f5e537dcefc0 100644
--- a/library/core/tests/option.rs
+++ b/library/core/tests/option.rs
@@ -7,7 +7,7 @@ use core::option::*;
 #[test]
 fn test_get_ptr() {
     unsafe {
-        let x: Box<_> = box 0;
+        let x: Box<_> = Box::new(0);
         let addr_x: *const isize = mem::transmute(&*x);
         let opt = Some(x);
         let y = opt.unwrap();
@@ -315,7 +315,7 @@ fn test_collect() {
 
     // test that it does not take more elements than it needs
     let mut functions: [Box<dyn Fn() -> Option<()>>; 3] =
-        [box || Some(()), box || None, box || panic!()];
+        [Box::new(|| Some(())), Box::new(|| None), Box::new(|| panic!())];
 
     let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();
 
diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs
index 98b870512b046..103e8cc3a96fa 100644
--- a/library/core/tests/result.rs
+++ b/library/core/tests/result.rs
@@ -69,7 +69,7 @@ fn test_collect() {
 
     // test that it does not take more elements than it needs
     let mut functions: [Box<dyn Fn() -> Result<(), isize>>; 3] =
-        [box || Ok(()), box || Err(1), box || panic!()];
+        [Box::new(|| Ok(())), Box::new(|| Err(1)), Box::new(|| panic!())];
 
     let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();
     assert!(v == Err(1));

From 5a4e9363a3fe142d5c7ea7acb8c61985fe34e704 Mon Sep 17 00:00:00 2001
From: Yuki Okushi <jtitor@2k36.org>
Date: Sun, 29 May 2022 11:29:49 +0900
Subject: [PATCH 4/8] Ensure source file present when calculating max line
 number

Co-authored-by: Ross MacArthur <ross@macarthur.io>
---
 compiler/rustc_errors/src/emitter.rs | 11 +++++++++--
 src/test/ui/span/issue-71363.rs      | 10 ++++++++++
 src/test/ui/span/issue-71363.stderr  | 27 +++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 src/test/ui/span/issue-71363.rs
 create mode 100644 src/test/ui/span/issue-71363.stderr

diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 5dd743e8d0023..3fdc8cf8ac25f 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1261,16 +1261,23 @@ impl EmitterWriter {
             return 0;
         };
 
+        let will_be_emitted = |span: Span| {
+            !span.is_dummy() && {
+                let file = sm.lookup_source_file(span.hi());
+                sm.ensure_source_file_source_present(file)
+            }
+        };
+
         let mut max = 0;
         for primary_span in msp.primary_spans() {
-            if !primary_span.is_dummy() {
+            if will_be_emitted(*primary_span) {
                 let hi = sm.lookup_char_pos(primary_span.hi());
                 max = (hi.line).max(max);
             }
         }
         if !self.short_message {
             for span_label in msp.span_labels() {
-                if !span_label.span.is_dummy() {
+                if will_be_emitted(span_label.span) {
                     let hi = sm.lookup_char_pos(span_label.span.hi());
                     max = (hi.line).max(max);
                 }
diff --git a/src/test/ui/span/issue-71363.rs b/src/test/ui/span/issue-71363.rs
new file mode 100644
index 0000000000000..3e85559caf923
--- /dev/null
+++ b/src/test/ui/span/issue-71363.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no
+// only-x86_64-unknown-linux-gnu
+//---^ Limiting target as the above unstable flags don't play well on some environment.
+
+struct MyError;
+impl std::error::Error for MyError {}
+//~^ ERROR: `MyError` doesn't implement `std::fmt::Display`
+//~| ERROR: `MyError` doesn't implement `Debug`
+
+fn main() {}
diff --git a/src/test/ui/span/issue-71363.stderr b/src/test/ui/span/issue-71363.stderr
new file mode 100644
index 0000000000000..d54f21752b89a
--- /dev/null
+++ b/src/test/ui/span/issue-71363.stderr
@@ -0,0 +1,27 @@
+error[E0277]: `MyError` doesn't implement `std::fmt::Display`
+ --> $DIR/issue-71363.rs:6:6
+  |
+6 | impl std::error::Error for MyError {}
+  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
+  |
+  = help: the trait `std::fmt::Display` is not implemented for `MyError`
+  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `std::error::Error`
+
+error[E0277]: `MyError` doesn't implement `Debug`
+ --> $DIR/issue-71363.rs:6:6
+  |
+6 | impl std::error::Error for MyError {}
+  |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
+  |
+  = help: the trait `Debug` is not implemented for `MyError`
+  = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
+note: required by a bound in `std::error::Error`
+help: consider annotating `MyError` with `#[derive(Debug)]`
+  |
+5 | #[derive(Debug)]
+  |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.

From c0f18f9412f222e7f314a637d69968618f633b01 Mon Sep 17 00:00:00 2001
From: binggh <binggh@proton.me>
Date: Sun, 29 May 2022 22:11:36 +0800
Subject: [PATCH 5/8] Re-add help_on_error for download-ci-llvm

Remove dead code

Missing }

./x.py fmt

Remove duplicate check

Recursively remove all usage of help_on_error
---
 src/bootstrap/bootstrap.py | 18 ++++++++----------
 src/bootstrap/builder.rs   | 15 ++++++++++++---
 src/bootstrap/config.rs    |  2 +-
 src/bootstrap/native.rs    | 10 +++++++++-
 4 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 955edd94c7828..a997c4f63abb8 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -63,7 +63,7 @@ def support_xz():
     except tarfile.CompressionError:
         return False
 
-def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error=None):
+def get(base, url, path, checksums, verbose=False, do_verify=True):
     with tempfile.NamedTemporaryFile(delete=False) as temp_file:
         temp_path = temp_file.name
 
@@ -86,7 +86,7 @@ def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error
                         print("ignoring already-download file",
                             path, "due to failed verification")
                     os.unlink(path)
-        download(temp_path, "{}/{}".format(base, url), True, verbose, help_on_error=help_on_error)
+        download(temp_path, "{}/{}".format(base, url), True, verbose)
         if do_verify and not verify(temp_path, sha256, verbose):
             raise RuntimeError("failed verification")
         if verbose:
@@ -99,17 +99,17 @@ def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error
             os.unlink(temp_path)
 
 
-def download(path, url, probably_big, verbose, help_on_error=None):
+def download(path, url, probably_big, verbose):
     for _ in range(0, 4):
         try:
-            _download(path, url, probably_big, verbose, True, help_on_error=help_on_error)
+            _download(path, url, probably_big, verbose, True)
             return
         except RuntimeError:
             print("\nspurious failure, trying again")
-    _download(path, url, probably_big, verbose, False, help_on_error=help_on_error)
+    _download(path, url, probably_big, verbose, False)
 
 
-def _download(path, url, probably_big, verbose, exception, help_on_error=None):
+def _download(path, url, probably_big, verbose, exception):
     # Try to use curl (potentially available on win32
     #    https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/)
     # If an error occurs:
@@ -134,7 +134,7 @@ def _download(path, url, probably_big, verbose, exception, help_on_error=None):
              "--retry", "3", "-Sf", "-o", path, url],
             verbose=verbose,
             exception=True, # Will raise RuntimeError on failure
-            help_on_error=help_on_error)
+        )
     except (subprocess.CalledProcessError, OSError, RuntimeError):
         # see http://serverfault.com/questions/301128/how-to-download
         if platform_is_win32:
@@ -186,7 +186,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
     shutil.rmtree(os.path.join(dst, fname))
 
 
-def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=None, **kwargs):
+def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
     """Run a child program in a new process"""
     if verbose:
         print("running: " + ' '.join(args))
@@ -197,8 +197,6 @@ def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=
     code = ret.wait()
     if code != 0:
         err = "failed to run: " + ' '.join(args)
-        if help_on_error is not None:
-            err += "\n" + help_on_error
         if verbose or exception:
             raise RuntimeError(err)
         # For most failures, we definitely do want to print this error, or the user will have no
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index d344c55158ac1..56d59c03e4992 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -869,15 +869,21 @@ impl<'a> Builder<'a> {
         self.try_run(patchelf.arg(fname));
     }
 
-    pub(crate) fn download_component(&self, base: &str, url: &str, dest_path: &Path) {
+    pub(crate) fn download_component(
+        &self,
+        base: &str,
+        url: &str,
+        dest_path: &Path,
+        help_on_error: &str,
+    ) {
         // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
         let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
         // FIXME: support `do_verify` (only really needed for nightly rustfmt)
-        self.download_with_retries(&tempfile, &format!("{}/{}", base, url));
+        self.download_with_retries(&tempfile, &format!("{}/{}", base, url), help_on_error);
         t!(std::fs::rename(&tempfile, dest_path));
     }
 
-    fn download_with_retries(&self, tempfile: &Path, url: &str) {
+    fn download_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
         println!("downloading {}", url);
         // Try curl. If that fails and we are on windows, fallback to PowerShell.
         let mut curl = Command::new("curl");
@@ -914,6 +920,9 @@ impl<'a> Builder<'a> {
                     println!("\nspurious failure, trying again");
                 }
             }
+            if !help_on_error.is_empty() {
+                eprintln!("{}", help_on_error);
+            }
             std::process::exit(1);
         }
     }
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 7775e0573704f..8e94fc7c4bea5 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -1491,7 +1491,7 @@ fn download_component(builder: &Builder<'_>, filename: String, prefix: &str, com
     let url = format!("rustc-builds/{commit}");
     let tarball = rustc_cache.join(&filename);
     if !tarball.exists() {
-        builder.download_component(base, &format!("{url}/{filename}"), &tarball);
+        builder.download_component(base, &format!("{url}/{filename}"), &tarball, "");
     }
     let bin_root = builder.out.join(builder.config.build.triple).join("ci-rustc");
     builder.unpack(&tarball, &bin_root, prefix)
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 72c2c2e654d15..cbd877e5f42b1 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -179,7 +179,15 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) {
     let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple);
     let tarball = rustc_cache.join(&filename);
     if !tarball.exists() {
-        builder.download_component(base, &format!("{}/{}", url, filename), &tarball);
+        let help_on_error = "error: failed to download llvm from ci\n
+\nhelp: old builds get deleted after a certain time
+\nhelp: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:
+\n
+\n[llvm]
+\ndownload-ci-llvm = false
+\n
+";
+        builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error);
     }
     let llvm_root = builder.config.ci_llvm_root();
     builder.unpack(&tarball, &llvm_root, "rust-dev");

From 2e25c2346b9cf58c3c30375bd6e6defef1c11f07 Mon Sep 17 00:00:00 2001
From: Michael Goulet <michael@errs.io>
Date: Sun, 29 May 2022 13:01:42 -0700
Subject: [PATCH 6/8] Note pattern mismatch coming from for-loop desugaring

---
 .../src/infer/error_reporting/mod.rs          |  9 +++++++-
 src/test/ui/pattern/for-loop-bad-item.rs      | 20 ++++++++++++++++
 src/test/ui/pattern/for-loop-bad-item.stderr  | 23 +++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 src/test/ui/pattern/for-loop-bad-item.rs
 create mode 100644 src/test/ui/pattern/for-loop-bad-item.stderr

diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 11c893a7cb6d9..e156930cc89fd 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -609,7 +609,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                 if !matches!(ty.kind(), ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_)))
                 {
                     // don't show type `_`
-                    err.span_label(span, format!("this expression has type `{}`", ty));
+                    if span.desugaring_kind() == Some(DesugaringKind::ForLoop)
+                    && let ty::Adt(def, substs) = ty.kind()
+                    && Some(def.did()) == self.tcx.get_diagnostic_item(sym::Option)
+                    {
+                        err.span_label(span, format!("this is an iterator with items of type `{}`", substs.type_at(0)));
+                    } else {
+                        err.span_label(span, format!("this expression has type `{}`", ty));
+                    }
                 }
                 if let Some(ty::error::ExpectedFound { found, .. }) = exp_found
                     && ty.is_box() && ty.boxed_ty() == found
diff --git a/src/test/ui/pattern/for-loop-bad-item.rs b/src/test/ui/pattern/for-loop-bad-item.rs
new file mode 100644
index 0000000000000..9a56a399b9b56
--- /dev/null
+++ b/src/test/ui/pattern/for-loop-bad-item.rs
@@ -0,0 +1,20 @@
+struct Qux(i32);
+
+fn bad() {
+    let mut map = std::collections::HashMap::new();
+    map.insert(('a', 'b'), ('c', 'd'));
+
+    for ((_, _), (&mut c, _)) in &mut map {
+    //~^ ERROR mismatched types
+        if c == 'e' {}
+    }
+}
+
+fn bad2() {
+    for Some(Qux(_)) | None in [Some(""), None] {
+    //~^ ERROR mismatched types
+        todo!();
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/pattern/for-loop-bad-item.stderr b/src/test/ui/pattern/for-loop-bad-item.stderr
new file mode 100644
index 0000000000000..9410e4da8d2af
--- /dev/null
+++ b/src/test/ui/pattern/for-loop-bad-item.stderr
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+  --> $DIR/for-loop-bad-item.rs:7:19
+   |
+LL |     for ((_, _), (&mut c, _)) in &mut map {
+   |                   ^^^^^^         -------- this is an iterator with items of type `(&(char, char), &mut (char, char))`
+   |                   |
+   |                   expected `char`, found `&mut _`
+   |                   help: you can probably remove the explicit borrow: `c`
+   |
+   = note:           expected type `char`
+           found mutable reference `&mut _`
+
+error[E0308]: mismatched types
+  --> $DIR/for-loop-bad-item.rs:14:14
+   |
+LL |     for Some(Qux(_)) | None in [Some(""), None] {
+   |              ^^^^^^            ---------------- this is an iterator with items of type `Option<&str>`
+   |              |
+   |              expected `str`, found struct `Qux`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.

From eeacb4403ca90b35443656a796ee53d29f3a25f1 Mon Sep 17 00:00:00 2001
From: Thom Chiovoloni <chiovolonit@gmail.com>
Date: Mon, 30 May 2022 01:06:08 -0700
Subject: [PATCH 7/8] Reword safety comments in core/hash/sip.rs

---
 library/core/src/hash/sip.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/library/core/src/hash/sip.rs b/library/core/src/hash/sip.rs
index c2ade8c7e54ed..97e32ca77db82 100644
--- a/library/core/src/hash/sip.rs
+++ b/library/core/src/hash/sip.rs
@@ -96,7 +96,8 @@ macro_rules! compress {
 /// `copy_nonoverlapping` to let the compiler generate the most efficient way
 /// to load it from a possibly unaligned address.
 ///
-/// Unsafe because: unchecked indexing at i..i+size_of(int_ty)
+/// Safety: this performs unchecked indexing of `$buf` at
+/// `$i..$i+size_of::<$int_ty>()`, so that must be in-bounds.
 macro_rules! load_int_le {
     ($buf:expr, $i:expr, $int_ty:ident) => {{
         debug_assert!($i + mem::size_of::<$int_ty>() <= $buf.len());
@@ -114,7 +115,8 @@ macro_rules! load_int_le {
 /// `copy_nonoverlapping` calls that occur (via `load_int_le!`) all have fixed
 /// sizes and avoid calling `memcpy`, which is good for speed.
 ///
-/// Unsafe because: unchecked indexing at start..start+len
+/// Safety: this performs unchecked indexing of `buf` at `start..start+len`, so
+/// that must be in-bounds.
 #[inline]
 unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
     debug_assert!(len < 8);

From 6d63d3b8889d36afbabcf6e70ad8710139c7b253 Mon Sep 17 00:00:00 2001
From: est31 <MTest31@outlook.com>
Date: Sun, 29 May 2022 01:00:24 +0200
Subject: [PATCH 8/8] Remove "sys isn't exported yet" phrase

The oldest occurence is from 9e224c2bf18ebf8f871efb2e1aba43ed7970ebb7,
which is from the pre-1.0 days. In the years since then, std::sys still
hasn't been exported, and the last attempt was met with strong criticism:
https://github.com/rust-lang/rust/pull/97151

Thus, removing the "yet" part makes a lot of sense.
---
 library/std/src/sys/unix/locks/pthread_mutex.rs | 1 -
 library/std/src/sys_common/thread_local_dtor.rs | 2 +-
 library/std/src/sys_common/thread_local_key.rs  | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/library/std/src/sys/unix/locks/pthread_mutex.rs b/library/std/src/sys/unix/locks/pthread_mutex.rs
index 09cfa2f50eced..76840ce74dd60 100644
--- a/library/std/src/sys/unix/locks/pthread_mutex.rs
+++ b/library/std/src/sys/unix/locks/pthread_mutex.rs
@@ -16,7 +16,6 @@ pub unsafe fn raw(m: &Mutex) -> *mut libc::pthread_mutex_t {
 unsafe impl Send for Mutex {}
 unsafe impl Sync for Mutex {}
 
-#[allow(dead_code)] // sys isn't exported yet
 impl Mutex {
     pub const fn new() -> Mutex {
         // Might be moved to a different address, so it is better to avoid
diff --git a/library/std/src/sys_common/thread_local_dtor.rs b/library/std/src/sys_common/thread_local_dtor.rs
index f9971fb6f21ef..1d13a7171b035 100644
--- a/library/std/src/sys_common/thread_local_dtor.rs
+++ b/library/std/src/sys_common/thread_local_dtor.rs
@@ -11,7 +11,7 @@
 //! or implement something more efficient.
 
 #![unstable(feature = "thread_local_internals", issue = "none")]
-#![allow(dead_code)] // sys isn't exported yet
+#![allow(dead_code)]
 
 use crate::ptr;
 use crate::sys_common::thread_local_key::StaticKey;
diff --git a/library/std/src/sys_common/thread_local_key.rs b/library/std/src/sys_common/thread_local_key.rs
index 32cd56416655f..70beebe86d20b 100644
--- a/library/std/src/sys_common/thread_local_key.rs
+++ b/library/std/src/sys_common/thread_local_key.rs
@@ -46,7 +46,7 @@
 
 #![allow(non_camel_case_types)]
 #![unstable(feature = "thread_local_internals", issue = "none")]
-#![allow(dead_code)] // sys isn't exported yet
+#![allow(dead_code)]
 
 #[cfg(test)]
 mod tests;