fix tests

This commit is contained in:
Jeremy Smart 2025-06-06 13:07:24 -04:00
parent 188c40126d
commit cc80429021
No known key found for this signature in database
GPG key ID: 5AD8086D5DF29A8F
4 changed files with 9 additions and 4 deletions

View file

@ -747,6 +747,7 @@ impl<T> Vec<T> {
/// Basic usage:
///
/// ```
/// #![feature(vec_peek_mut)]
/// let mut vec = Vec::new();
/// assert!(vec.peek_mut().is_none());
///

View file

@ -42,7 +42,6 @@
#![feature(trusted_random_access)]
#![feature(try_reserve_kind)]
#![feature(try_trait_v2)]
#![feature(vec_peek_mut)]
// tidy-alphabetical-end
//
// Language features:

View file

@ -40,6 +40,7 @@
#![feature(vec_deque_truncate_front)]
#![feature(unique_rc_arc)]
#![feature(macro_metavar_expr_concat)]
#![feature(vec_peek_mut)]
#![allow(internal_features)]
#![deny(fuzzy_provenance_casts)]
#![deny(unsafe_op_in_unsafe_fn)]

View file

@ -2704,9 +2704,13 @@ fn test_peek_mut() {
assert!(vec.peek_mut().is_none());
vec.push(1);
vec.push(2);
assert_eq!(vec.peek_mut(), Some(2));
*vec.peek_mut() = 0;
assert_eq!(vec.peek_mut(), Some(0));
if let Some(mut p) = vec.peek_mut() {
assert_eq!(*p, 2);
*p = 0;
assert_eq!(*p, 0);
} else {
unreachable!()
}
}
/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments