@@ -127,6 +127,8 @@ macro_rules! assert_ne {
127127/// ```
128128/// #![feature(assert_matches)]
129129///
130+ /// use std::assert::assert_matches;
131+ ///
130132/// let a = 1u32.checked_add(2);
131133/// let b = 1u32.checked_sub(2);
132134/// assert_matches!(a, Some(_));
@@ -135,10 +137,10 @@ macro_rules! assert_ne {
135137/// let c = Ok("abc".to_string());
136138/// assert_matches!(c, Ok(x) | Err(x) if x.len() < 100);
137139/// ```
138- #[ macro_export]
139140#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
140141#[ allow_internal_unstable( core_panic) ]
141- macro_rules! assert_matches {
142+ #[ rustc_macro_transparency = "semitransparent" ]
143+ pub macro assert_matches {
142144 ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
143145 match $left {
144146 $( $pattern ) |+ $( if $guard ) ? => { }
@@ -150,7 +152,7 @@ macro_rules! assert_matches {
150152 ) ;
151153 }
152154 }
153- } ) ;
155+ } ) ,
154156 ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
155157 match $left {
156158 $( $pattern ) |+ $( if $guard ) ? => { }
@@ -162,7 +164,7 @@ macro_rules! assert_matches {
162164 ) ;
163165 }
164166 }
165- } ) ;
167+ } ) ,
166168}
167169
168170/// Asserts that a boolean expression is `true` at runtime.
@@ -284,6 +286,8 @@ macro_rules! debug_assert_ne {
284286/// ```
285287/// #![feature(assert_matches)]
286288///
289+ /// use std::assert::debug_assert_matches;
290+ ///
287291/// let a = 1u32.checked_add(2);
288292/// let b = 1u32.checked_sub(2);
289293/// debug_assert_matches!(a, Some(_));
@@ -295,8 +299,9 @@ macro_rules! debug_assert_ne {
295299 #[ macro_export]
296300#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
297301#[ 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) * ) ; }
300305}
301306
302307/// Returns whether the given expression matches any of the given patterns.
0 commit comments