@@ -126,6 +126,8 @@ macro_rules! assert_ne {
126126/// ```
127127/// #![feature(assert_matches)]
128128///
129+ /// use std::assert::assert_matches;
130+ ///
129131/// let a = 1u32.checked_add(2);
130132/// let b = 1u32.checked_sub(2);
131133/// assert_matches!(a, Some(_));
@@ -134,10 +136,10 @@ macro_rules! assert_ne {
134136/// let c = Ok("abc".to_string());
135137/// assert_matches!(c, Ok(x) | Err(x) if x.len() < 100);
136138/// ```
137- #[ macro_export]
138139#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
139140#[ allow_internal_unstable( core_panic) ]
140- macro_rules! assert_matches {
141+ #[ rustc_macro_transparency = "semitransparent" ]
142+ pub macro assert_matches {
141143 ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
142144 match $left {
143145 $( $pattern ) |+ $( if $guard ) ? => { }
@@ -149,7 +151,7 @@ macro_rules! assert_matches {
149151 ) ;
150152 }
151153 }
152- } ) ;
154+ } ) ,
153155 ( $left: expr, $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
154156 match $left {
155157 $( $pattern ) |+ $( if $guard ) ? => { }
@@ -161,7 +163,7 @@ macro_rules! assert_matches {
161163 ) ;
162164 }
163165 }
164- } ) ;
166+ } ) ,
165167}
166168
167169/// Asserts that a boolean expression is `true` at runtime.
@@ -283,6 +285,8 @@ macro_rules! debug_assert_ne {
283285/// ```
284286/// #![feature(assert_matches)]
285287///
288+ /// use std::assert::debug_assert_matches;
289+ ///
286290/// let a = 1u32.checked_add(2);
287291/// let b = 1u32.checked_sub(2);
288292/// debug_assert_matches!(a, Some(_));
@@ -294,8 +298,9 @@ macro_rules! debug_assert_ne {
294298 #[ macro_export]
295299#[ unstable( feature = "assert_matches" , issue = "82775" ) ]
296300#[ 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) * ) ; }
299304}
300305
301306/// Returns whether the given expression matches any of the given patterns.
0 commit comments