Skip to content

Commit f223aff

Browse files
committed
Don't consume the expression in assert_matches!()'s failure case.
1 parent 5bd1204 commit f223aff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/macros/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ macro_rules! assert_matches {
141141
($left:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => ({
142142
match $left {
143143
$( $pattern )|+ $( if $guard )? => {}
144-
left_val => {
144+
ref left_val => {
145145
$crate::panicking::assert_matches_failed(
146-
&left_val,
146+
left_val,
147147
$crate::stringify!($($pattern)|+ $(if $guard)?),
148148
$crate::option::Option::None
149149
);
@@ -153,9 +153,9 @@ macro_rules! assert_matches {
153153
($left:expr, $( $pattern:pat )|+ $( if $guard: expr )?, $($arg:tt)+) => ({
154154
match $left {
155155
$( $pattern )|+ $( if $guard )? => {}
156-
left_val => {
156+
ref left_val => {
157157
$crate::panicking::assert_matches_failed(
158-
&left_val,
158+
left_val,
159159
$crate::stringify!($($pattern)|+ $(if $guard)?),
160160
$crate::option::Option::Some($crate::format_args!($($arg)+))
161161
);

0 commit comments

Comments
 (0)