diff options
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 1 | ||||
| -rw-r--r-- | library/alloctests/lib.rs | 1 | ||||
| -rw-r--r-- | library/alloctests/tests/lib.rs | 1 | ||||
| -rw-r--r-- | library/alloctests/tests/vec.rs | 10 |
4 files changed, 9 insertions, 4 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 8763ce674be..96d082aba22 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -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()); /// diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 232cf06fff9..56e60ed4c84 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -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: diff --git a/library/alloctests/tests/lib.rs b/library/alloctests/tests/lib.rs index 38309585fad..a41162ecd51 100644 --- a/library/alloctests/tests/lib.rs +++ b/library/alloctests/tests/lib.rs @@ -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)] diff --git a/library/alloctests/tests/vec.rs b/library/alloctests/tests/vec.rs index 0de9da37561..adbd4ccb897 100644 --- a/library/alloctests/tests/vec.rs +++ b/library/alloctests/tests/vec.rs @@ -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 |
