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