@@ -126,6 +126,8 @@ macro_rules! assert_ne {
126
126
/// ```
127
127
/// #![feature(assert_matches)]
128
128
///
129
+ /// use std::assert::assert_matches;
130
+ ///
129
131
/// let a = 1u32.checked_add(2);
130
132
/// let b = 1u32.checked_sub(2);
131
133
/// assert_matches!(a, Some(_));
@@ -134,10 +136,10 @@ macro_rules! assert_ne {
134
136
/// let c = Ok("abc".to_string());
135
137
/// assert_matches!(c, Ok(x) | Err(x) if x.len() < 100);
136
138
/// ```
137
- #[ macro_export]
138
139
#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
139
140
#[ allow_internal_unstable( core_panic) ]
140
- macro_rules! assert_matches {
141
+ #[ rustc_macro_transparency = "semitransparent" ]
142
+ pub macro assert_matches {
141
143
( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
142
144
match $left {
143
145
$( $pattern ) |+ $( if $guard ) ? => { }
@@ -149,7 +151,7 @@ macro_rules! assert_matches {
149
151
) ;
150
152
}
151
153
}
152
- } ) ;
154
+ } ) ,
153
155
( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
154
156
match $left {
155
157
$( $pattern ) |+ $( if $guard ) ? => { }
@@ -161,7 +163,7 @@ macro_rules! assert_matches {
161
163
) ;
162
164
}
163
165
}
164
- } ) ;
166
+ } ) ,
165
167
}
166
168
167
169
/// Asserts that a boolean expression is `true` at runtime.
@@ -283,6 +285,8 @@ macro_rules! debug_assert_ne {
283
285
/// ```
284
286
/// #![feature(assert_matches)]
285
287
///
288
+ /// use std::assert::debug_assert_matches;
289
+ ///
286
290
/// let a = 1u32.checked_add(2);
287
291
/// let b = 1u32.checked_sub(2);
288
292
/// debug_assert_matches!(a, Some(_));
@@ -294,8 +298,9 @@ macro_rules! debug_assert_ne {
294
298
#[ macro_export]
295
299
#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
296
300
#[ allow_internal_unstable( assert_matches) ]
297
- macro_rules! debug_assert_matches {
298
- ( $( $arg: tt) * ) => ( if $crate:: cfg!( debug_assertions) { $crate:: assert_matches!( $( $arg) * ) ; } )
301
+ #[ rustc_macro_transparency = "semitransparent" ]
302
+ pub macro debug_assert_matches( $( $arg: tt) * ) {
303
+ if $crate :: cfg!( debug_assertions) { $crate :: assert:: assert_matches!( $( $arg) * ) ; }
299
304
}
300
305
301
306
/// Returns whether the given expression matches any of the given patterns.
0 commit comments