diff --git a/src/macros.rs b/src/macros.rs index b09afa4..a0f4cae 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -173,8 +173,9 @@ macro_rules! anyhow { }; ($err:expr $(,)?) => ({ use $crate::private::kind::*; - let error = $err; - (&error).anyhow_kind().new(error) + match $err { + error => (&error).anyhow_kind().new(error), + } }); ($fmt:expr, $($arg:tt)*) => { $crate::private::new_adhoc(format!($fmt, $($arg)*)) diff --git a/tests/ui/temporary-value.stderr b/tests/ui/temporary-value.stderr index b73a9a1..fa753d2 100644 --- a/tests/ui/temporary-value.stderr +++ b/tests/ui/temporary-value.stderr @@ -2,8 +2,7 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/temporary-value.rs:4:22 | 4 | let _ = anyhow!(&String::new()); - | ---------^^^^^^^^^^^^^- + | ---------^^^^^^^^^^^^^-- temporary value is freed at the end of this statement | | | | | creates a temporary which is freed while still in use - | temporary value is freed at the end of this statement | argument requires that borrow lasts for `'static`