Skip to content

Commit cc80429

Browse files
committed
fix tests
1 parent 188c401 commit cc80429

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ impl<T> Vec<T> {
747747
/// Basic usage:
748748
///
749749
/// ```
750+
/// #![feature(vec_peek_mut)]
750751
/// let mut vec = Vec::new();
751752
/// assert!(vec.peek_mut().is_none());
752753
///

library/alloctests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#![feature(trusted_random_access)]
4343
#![feature(try_reserve_kind)]
4444
#![feature(try_trait_v2)]
45-
#![feature(vec_peek_mut)]
4645
// tidy-alphabetical-end
4746
//
4847
// Language features:

library/alloctests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#![feature(vec_deque_truncate_front)]
4141
#![feature(unique_rc_arc)]
4242
#![feature(macro_metavar_expr_concat)]
43+
#![feature(vec_peek_mut)]
4344
#![allow(internal_features)]
4445
#![deny(fuzzy_provenance_casts)]
4546
#![deny(unsafe_op_in_unsafe_fn)]

library/alloctests/tests/vec.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,9 +2704,13 @@ fn test_peek_mut() {
27042704
assert!(vec.peek_mut().is_none());
27052705
vec.push(1);
27062706
vec.push(2);
2707-
assert_eq!(vec.peek_mut(), Some(2));
2708-
*vec.peek_mut() = 0;
2709-
assert_eq!(vec.peek_mut(), Some(0));
2707+
if let Some(mut p) = vec.peek_mut() {
2708+
assert_eq!(*p, 2);
2709+
*p = 0;
2710+
assert_eq!(*p, 0);
2711+
} else {
2712+
unreachable!()
2713+
}
27102714
}
27112715

27122716
/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments

0 commit comments

Comments
 (0)