about summary refs log tree commit diff
path: root/library/core/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-28 18:49:55 +0000
committerbors <bors@rust-lang.org>2024-07-28 18:49:55 +0000
commit2cbbe8b8bb2be672b14cf741a2f0ec24a49f3f0b (patch)
tree2b2d6044bc2153a15d65e9ae7abd307f52c9adef /library/core/tests
parent188ddf4d6a694fa263c2ff8be8f8eade659599d6 (diff)
parenteeb76ccaf0f20819c1e4360420e7b1aff94c5c9d (diff)
Auto merge of #128313 - GuillaumeGomez:rollup-kacb489, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #125779 ([rustdoc] Add copy code feature)
 - #127765 (Fix doc nits)
 - #127860 (deps: dedup object, wasmparser, wasm-encoder)
 - #128103 (add `is_multiple_of` for unsigned integer types)
 - #128228 (Stabilize `const_waker`)
 - #128240 (Add links from `assert_eq!` docs to `debug_assert_eq!`, etc.)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/core/tests')
-rw-r--r--library/core/tests/lib.rs2
-rw-r--r--library/core/tests/num/uint_macros.rs8
-rw-r--r--library/core/tests/ptr.rs2
-rw-r--r--library/core/tests/waker.rs32
4 files changed, 42 insertions, 2 deletions
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 51d57c9e37d..5dad5937a60 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -59,6 +59,7 @@
 #![feature(num_midpoint)]
 #![feature(offset_of_nested)]
 #![feature(isqrt)]
+#![feature(unsigned_is_multiple_of)]
 #![feature(step_trait)]
 #![feature(str_internals)]
 #![feature(std_internals)]
@@ -86,7 +87,6 @@
 #![feature(const_ipv6)]
 #![feature(const_mut_refs)]
 #![feature(const_pin)]
-#![feature(const_waker)]
 #![feature(never_type)]
 #![feature(unwrap_infallible)]
 #![feature(pointer_is_aligned_to)]
diff --git a/library/core/tests/num/uint_macros.rs b/library/core/tests/num/uint_macros.rs
index 955440647eb..d009ad89d5c 100644
--- a/library/core/tests/num/uint_macros.rs
+++ b/library/core/tests/num/uint_macros.rs
@@ -261,6 +261,14 @@ macro_rules! uint_module {
             }
 
             #[test]
+            fn test_is_next_multiple_of() {
+                assert!((12 as $T).is_multiple_of(4));
+                assert!(!(12 as $T).is_multiple_of(5));
+                assert!((0 as $T).is_multiple_of(0));
+                assert!(!(12 as $T).is_multiple_of(0));
+            }
+
+            #[test]
             fn test_carrying_add() {
                 assert_eq!($T::MAX.carrying_add(1, false), (0, true));
                 assert_eq!($T::MAX.carrying_add(0, true), (0, true));
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
index e3830165eda..bc1940ebf32 100644
--- a/library/core/tests/ptr.rs
+++ b/library/core/tests/ptr.rs
@@ -1050,7 +1050,7 @@ fn nonnull_tagged_pointer_with_provenance() {
         /// A mask for the non-data-carrying bits of the address.
         pub const ADDRESS_MASK: usize = usize::MAX << Self::NUM_BITS;
 
-        /// Create a new tagged pointer from a possibly null pointer.
+        /// Creates a new tagged pointer from a possibly null pointer.
         pub fn new(pointer: *mut T) -> Option<TaggedPointer<T>> {
             Some(TaggedPointer(NonNull::new(pointer)?))
         }
diff --git a/library/core/tests/waker.rs b/library/core/tests/waker.rs
index 2c66e0d7ad3..f8c91a72593 100644
--- a/library/core/tests/waker.rs
+++ b/library/core/tests/waker.rs
@@ -20,3 +20,35 @@ static WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
     |_| {},
     |_| {},
 );
+
+// https://github.com/rust-lang/rust/issues/102012#issuecomment-1915282956
+mod nop_waker {
+    use core::{
+        future::{ready, Future},
+        pin::Pin,
+        task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
+    };
+
+    const NOP_RAWWAKER: RawWaker = {
+        fn nop(_: *const ()) {}
+        const VTAB: RawWakerVTable = RawWakerVTable::new(|_| NOP_RAWWAKER, nop, nop, nop);
+        RawWaker::new(&() as *const (), &VTAB)
+    };
+
+    const NOP_WAKER: &Waker = &unsafe { Waker::from_raw(NOP_RAWWAKER) };
+
+    const NOP_CONTEXT: Context<'static> = Context::from_waker(NOP_WAKER);
+
+    fn poll_once<T, F>(f: &mut F) -> Poll<T>
+    where
+        F: Future<Output = T> + ?Sized + Unpin,
+    {
+        let mut cx = NOP_CONTEXT;
+        Pin::new(f).as_mut().poll(&mut cx)
+    }
+
+    #[test]
+    fn test_const_waker() {
+        assert_eq!(poll_once(&mut ready(1)), Poll::Ready(1));
+    }
+}