summaryrefslogtreecommitdiffstats
path: root/library/core/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /library/core/tests
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/tests')
-rw-r--r--library/core/tests/array.rs15
-rw-r--r--library/core/tests/clone.rs2
-rw-r--r--library/core/tests/future.rs1
-rw-r--r--library/core/tests/iter/adapters/step_by.rs55
-rw-r--r--library/core/tests/lib.rs2
-rw-r--r--library/core/tests/manually_drop.rs2
-rw-r--r--library/core/tests/mem.rs11
-rw-r--r--library/core/tests/net/ip_addr.rs6
-rw-r--r--library/core/tests/net/socket_addr.rs2
-rw-r--r--library/core/tests/ptr.rs2
10 files changed, 68 insertions, 30 deletions
diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs
index 0869644c0..982d7853f 100644
--- a/library/core/tests/array.rs
+++ b/library/core/tests/array.rs
@@ -257,14 +257,8 @@ fn iterator_drops() {
assert_eq!(i.get(), 5);
}
-// This test does not work on targets without panic=unwind support.
-// To work around this problem, test is marked is should_panic, so it will
-// be automagically skipped on unsuitable targets, such as
-// wasm32-unknown-unknown.
-//
-// It means that we use panic for indicating success.
-#[test]
-#[should_panic(expected = "test succeeded")]
+#[test]
+#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn array_default_impl_avoids_leaks_on_panic() {
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
static COUNTER: AtomicUsize = AtomicUsize::new(0);
@@ -296,7 +290,6 @@ fn array_default_impl_avoids_leaks_on_panic() {
assert_eq!(*panic_msg, "bomb limit exceeded");
// check that all bombs are successfully dropped
assert_eq!(COUNTER.load(Relaxed), 0);
- panic!("test succeeded")
}
#[test]
@@ -317,9 +310,8 @@ fn array_map() {
assert_eq!(b, [1, 2, 3]);
}
-// See note on above test for why `should_panic` is used.
#[test]
-#[should_panic(expected = "test succeeded")]
+#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
fn array_map_drop_safety() {
static DROPPED: AtomicUsize = AtomicUsize::new(0);
struct DropCounter;
@@ -341,7 +333,6 @@ fn array_map_drop_safety() {
});
assert!(success.is_err());
assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create);
- panic!("test succeeded")
}
#[test]
diff --git a/library/core/tests/clone.rs b/library/core/tests/clone.rs
index aafe5ced2..64193e115 100644
--- a/library/core/tests/clone.rs
+++ b/library/core/tests/clone.rs
@@ -1,5 +1,5 @@
#[test]
-#[cfg_attr(not(bootstrap), allow(suspicious_double_ref_op))]
+#[allow(suspicious_double_ref_op)]
fn test_borrowed_clone() {
let x = 5;
let y: &i32 = &x;
diff --git a/library/core/tests/future.rs b/library/core/tests/future.rs
index 74b6f74e4..db417256d 100644
--- a/library/core/tests/future.rs
+++ b/library/core/tests/future.rs
@@ -30,7 +30,6 @@ fn poll_n(val: usize, num: usize) -> PollN {
}
#[test]
-#[cfg_attr(miri, ignore)] // self-referential generators do not work with Miri's aliasing checks
fn test_join() {
block_on(async move {
let x = join!(async { 0 }).await;
diff --git a/library/core/tests/iter/adapters/step_by.rs b/library/core/tests/iter/adapters/step_by.rs
index 94f2fa8c2..4c5b1dd9a 100644
--- a/library/core/tests/iter/adapters/step_by.rs
+++ b/library/core/tests/iter/adapters/step_by.rs
@@ -244,3 +244,58 @@ fn test_step_by_skip() {
assert_eq!((0..=50).step_by(10).nth(3), Some(30));
assert_eq!((200..=255u8).step_by(10).nth(3), Some(230));
}
+
+
+struct DeOpt<I: Iterator>(I);
+
+impl<I: Iterator> Iterator for DeOpt<I> {
+ type Item = I::Item;
+
+ fn next(&mut self) -> core::option::Option<Self::Item> {
+ self.0.next()
+ }
+}
+
+impl<I: DoubleEndedIterator> DoubleEndedIterator for DeOpt<I> {
+ fn next_back(&mut self) -> core::option::Option<Self::Item> {
+ self.0.next_back()
+ }
+}
+
+#[test]
+fn test_step_by_fold_range_specialization() {
+ macro_rules! t {
+ ($range:expr, $var: ident, $body:tt) => {
+ {
+ // run the same tests for the non-optimized version
+ let mut $var = DeOpt($range);
+ $body
+ }
+ {
+ let mut $var = $range;
+ $body
+ }
+ }
+ }
+
+ t!((1usize..5).step_by(1), r, {
+ assert_eq!(r.next_back(), Some(4));
+ assert_eq!(r.sum::<usize>(), 6);
+ });
+
+ t!((0usize..4).step_by(2), r, {
+ assert_eq!(r.next(), Some(0));
+ assert_eq!(r.sum::<usize>(), 2);
+ });
+
+
+ t!((0usize..5).step_by(2), r, {
+ assert_eq!(r.next(), Some(0));
+ assert_eq!(r.sum::<usize>(), 6);
+ });
+
+ t!((usize::MAX - 6 .. usize::MAX).step_by(5), r, {
+ assert_eq!(r.next(), Some(usize::MAX - 6));
+ assert_eq!(r.sum::<usize>(), usize::MAX - 1);
+ });
+}
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 3933e3289..3e6d31fcd 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -109,7 +109,7 @@
#![feature(utf8_chunks)]
#![feature(is_ascii_octdigit)]
#![feature(get_many_mut)]
-#![cfg_attr(not(bootstrap), feature(offset_of))]
+#![feature(offset_of)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(fuzzy_provenance_casts)]
diff --git a/library/core/tests/manually_drop.rs b/library/core/tests/manually_drop.rs
index 9eac27973..22d72d219 100644
--- a/library/core/tests/manually_drop.rs
+++ b/library/core/tests/manually_drop.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(not(bootstrap), allow(undropped_manually_drops))]
+
use core::mem::ManuallyDrop;
#[test]
diff --git a/library/core/tests/mem.rs b/library/core/tests/mem.rs
index aee9c89b5..5c2e18745 100644
--- a/library/core/tests/mem.rs
+++ b/library/core/tests/mem.rs
@@ -366,7 +366,6 @@ fn const_maybe_uninit() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of() {
#[repr(C)]
struct Foo {
@@ -391,7 +390,7 @@ fn offset_of() {
struct Generic<T> {
x: u8,
y: u32,
- z: T
+ z: T,
}
trait Trait {}
@@ -409,7 +408,6 @@ fn offset_of() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_union() {
#[repr(C)]
union Foo {
@@ -429,7 +427,6 @@ fn offset_of_union() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_dst() {
#[repr(C)]
struct Alpha {
@@ -469,7 +466,6 @@ fn offset_of_dst() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_packed() {
#[repr(C, packed)]
struct Foo {
@@ -482,7 +478,6 @@ fn offset_of_packed() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_projection() {
#[repr(C)]
struct Foo {
@@ -503,7 +498,6 @@ fn offset_of_projection() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_alias() {
#[repr(C)]
struct Foo {
@@ -518,7 +512,6 @@ fn offset_of_alias() {
}
#[test]
-#[cfg(not(bootstrap))]
fn const_offset_of() {
#[repr(C)]
struct Foo {
@@ -534,7 +527,6 @@ fn const_offset_of() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_without_const_promotion() {
#[repr(C)]
struct Foo<SuppressConstPromotion> {
@@ -555,7 +547,6 @@ fn offset_of_without_const_promotion() {
}
#[test]
-#[cfg(not(bootstrap))]
fn offset_of_addr() {
#[repr(C)]
struct Foo {
diff --git a/library/core/tests/net/ip_addr.rs b/library/core/tests/net/ip_addr.rs
index 5a6ac08c0..7530fc084 100644
--- a/library/core/tests/net/ip_addr.rs
+++ b/library/core/tests/net/ip_addr.rs
@@ -139,7 +139,7 @@ fn ipv6_addr_to_string() {
// ipv4-compatible address
let a1 = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0xc000, 0x280);
- assert_eq!(a1.to_string(), "::192.0.2.128");
+ assert_eq!(a1.to_string(), "::c000:280");
// v6 address with no zero segments
assert_eq!(Ipv6Addr::new(8, 9, 10, 11, 12, 13, 14, 15).to_string(), "8:9:a:b:c:d:e:f");
@@ -316,7 +316,7 @@ fn ip_properties() {
check!("::", unspec);
check!("::1", loopback);
- check!("::0.0.0.2", global);
+ check!("::2", global);
check!("1::", global);
check!("fc00::");
check!("fdff:ffff::");
@@ -607,7 +607,7 @@ fn ipv6_properties() {
check!("::1", &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], loopback);
- check!("::0.0.0.2", &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], global | unicast_global);
+ check!("::2", &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], global | unicast_global);
check!("1::", &[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], global | unicast_global);
diff --git a/library/core/tests/net/socket_addr.rs b/library/core/tests/net/socket_addr.rs
index 68c7cd94d..35a69cead 100644
--- a/library/core/tests/net/socket_addr.rs
+++ b/library/core/tests/net/socket_addr.rs
@@ -34,7 +34,7 @@ fn ipv6_socket_addr_to_string() {
// IPv4-compatible address.
assert_eq!(
SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0xc000, 0x280), 8080, 0, 0).to_string(),
- "[::192.0.2.128]:8080"
+ "[::c000:280]:8080"
);
// IPv6 address with no zero segments.
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
index c02cd99cc..ee885adfe 100644
--- a/library/core/tests/ptr.rs
+++ b/library/core/tests/ptr.rs
@@ -1001,7 +1001,7 @@ fn nonnull_tagged_pointer_with_provenance() {
assert_eq!(p.tag(), 3);
assert_eq!(unsafe { *p.pointer().as_ptr() }, 10);
- unsafe { Box::from_raw(p.pointer().as_ptr()) };
+ unsafe { drop(Box::from_raw(p.pointer().as_ptr())) };
/// A non-null pointer type which carries several bits of metadata and maintains provenance.
#[repr(transparent)]