Skip to content

Commit f03c1a2

Browse files
Rollup merge of rust-lang#151423 - Voultapher:move-assert-matches, r=Amanieu
Move assert_matches to planned stable path Another prep PR for rust-lang#137487
2 parents 96a40e9 + 58be5d6 commit f03c1a2

27 files changed

Lines changed: 43 additions & 40 deletions

File tree

compiler/rustc_data_structures/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
// have to worry about it being moved to a different module in std during stabilization.
4242
// FIXME(#151359): Remove this when `feature(assert_matches)` is stable in stage0.
4343
// (This doesn't necessarily need to be fixed during the beta bump itself.)
44+
#[cfg(bootstrap)]
4445
pub use std::assert_matches::{assert_matches, debug_assert_matches};
4546
use std::fmt;
47+
#[cfg(not(bootstrap))]
48+
pub use std::{assert_matches, debug_assert_matches};
4649

4750
pub use atomic_ref::AtomicRef;
4851
pub use ena::{snapshot_vec, undo_log, unify};

library/alloc/src/collections/btree/map/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::assert_matches::assert_matches;
1+
use core::assert_matches;
22
use std::iter;
33
use std::ops::Bound::{Excluded, Included, Unbounded};
44
use std::panic::{AssertUnwindSafe, catch_unwind};

library/alloctests/tests/c_str2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloc::ffi::CString;
22
use alloc::rc::Rc;
33
use alloc::sync::Arc;
4-
use core::assert_matches::assert_matches;
4+
use core::assert_matches;
55
use core::ffi::{CStr, FromBytesUntilNulError, c_char};
66
#[allow(deprecated)]
77
use core::hash::SipHasher13 as DefaultHasher;

library/alloctests/tests/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(invalid_from_utf8)]
22

3-
use std::assert_matches::assert_matches;
3+
use std::assert_matches;
44
use std::borrow::Cow;
55
use std::cmp::Ordering::{Equal, Greater, Less};
66
use std::str::{from_utf8, from_utf8_unchecked};

library/alloctests/tests/string.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::assert_matches::assert_matches;
21
use std::borrow::Cow;
32
use std::cell::Cell;
43
use std::collections::TryReserveErrorKind::*;
54
use std::ops::Bound::*;
65
use std::ops::{Bound, RangeBounds};
7-
use std::{panic, str};
6+
use std::{assert_matches, panic, str};
87

98
pub trait IntoCow<'a, B: ?Sized>
109
where

library/alloctests/tests/vec.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ use core::num::NonZero;
33
use core::ptr::NonNull;
44
use core::{assert_eq, assert_ne};
55
use std::alloc::System;
6-
use std::assert_matches::assert_matches;
76
use std::borrow::Cow;
87
use std::cell::Cell;
98
use std::collections::TryReserveErrorKind::*;
109
use std::fmt::Debug;
11-
use std::hint;
1210
use std::iter::InPlaceIterable;
1311
use std::mem::swap;
1412
use std::ops::Bound::*;
1513
use std::panic::{AssertUnwindSafe, catch_unwind};
1614
use std::rc::Rc;
1715
use std::sync::atomic::{AtomicU32, Ordering};
1816
use std::vec::{Drain, IntoIter, PeekMut};
17+
use std::{assert_matches, hint};
1918

2019
use crate::testing::macros::struct_with_counted_drop;
2120

library/alloctests/tests/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::cell::Cell;
22
use core::num::NonZero;
3-
use std::assert_matches::assert_matches;
3+
use std::assert_matches;
44
use std::collections::TryReserveErrorKind::*;
55
use std::collections::VecDeque;
66
use std::collections::vec_deque::Drain;

library/core/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,7 @@ use prelude::rust_2024::*;
223223
mod macros;
224224

225225
#[unstable(feature = "assert_matches", issue = "82775")]
226-
/// Unstable module containing the unstable `assert_matches` macro.
227-
pub mod assert_matches {
228-
#[unstable(feature = "assert_matches", issue = "82775")]
229-
pub use crate::macros::{assert_matches, debug_assert_matches};
230-
}
226+
pub use crate::macros::{assert_matches, debug_assert_matches};
231227

232228
#[unstable(feature = "derive_from", issue = "144889")]
233229
/// Unstable module containing the unstable `From` derive macro.

library/core/src/macros/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ macro_rules! assert_ne {
124124
};
125125
}
126126

127+
// FIXME add back debug_assert_matches doc link after bootstrap.
128+
127129
/// Asserts that an expression matches the provided pattern.
128130
///
129131
/// This macro is generally preferable to `assert!(matches!(value, pattern))`, because it can print
@@ -135,11 +137,9 @@ macro_rules! assert_ne {
135137
/// otherwise this macro will panic.
136138
///
137139
/// Assertions are always checked in both debug and release builds, and cannot
138-
/// be disabled. See [`debug_assert_matches!`] for assertions that are disabled in
140+
/// be disabled. See `debug_assert_matches!` for assertions that are disabled in
139141
/// release builds by default.
140142
///
141-
/// [`debug_assert_matches!`]: crate::assert_matches::debug_assert_matches
142-
///
143143
/// On panic, this macro will print the value of the expression with its debug representation.
144144
///
145145
/// Like [`assert!`], this macro has a second form, where a custom panic message can be provided.
@@ -149,7 +149,7 @@ macro_rules! assert_ne {
149149
/// ```
150150
/// #![feature(assert_matches)]
151151
///
152-
/// use std::assert_matches::assert_matches;
152+
/// use std::assert_matches;
153153
///
154154
/// let a = Some(345);
155155
/// let b = Some(56);
@@ -382,7 +382,7 @@ macro_rules! debug_assert_ne {
382382
/// ```
383383
/// #![feature(assert_matches)]
384384
///
385-
/// use std::assert_matches::debug_assert_matches;
385+
/// use std::debug_assert_matches;
386386
///
387387
/// let a = Some(345);
388388
/// let b = Some(56);
@@ -404,7 +404,7 @@ macro_rules! debug_assert_ne {
404404
#[rustc_macro_transparency = "semiopaque"]
405405
pub macro debug_assert_matches($($arg:tt)*) {
406406
if $crate::cfg!(debug_assertions) {
407-
$crate::assert_matches::assert_matches!($($arg)*);
407+
$crate::assert_matches!($($arg)*);
408408
}
409409
}
410410

library/std/src/collections/hash/map/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use realstd::collections::TryReserveErrorKind::*;
33

44
use super::Entry::{Occupied, Vacant};
55
use super::HashMap;
6-
use crate::assert_matches::assert_matches;
6+
use crate::assert_matches;
77
use crate::cell::RefCell;
88
use crate::hash::{BuildHasher, BuildHasherDefault, DefaultHasher, RandomState};
99
use crate::test_helpers::test_rng;

0 commit comments

Comments
 (0)