Skip to content
Myr

Add must_use to value created by anyhow! macro

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 1af20cc · Browse files · 2 files+23 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−11 removed

  • other:+23 added−11 removed

2 files+23 added−11 removed

modified:src/lib.rs+8 added
666 unmodified lines
667 // anyhow!("interpolate {var}"), can downcast to String668 Error::msg(fmt::format(args))669 }670 }671672 #[doc(hidden)]673 #[inline]674 #[cold]675 #[must_use]676 pub fn must_use(error: Error) -> Error {677 error678 }679}
modified:src/macros.rs+15 added-11 removed
204 unmodified lines
205/// }206/// ```207#[macro_export]208macro_rules! anyhow {209 ($msg:literal $(,)?) => ({210 let error = $crate::private::format_err($crate::private::format_args!($msg));211 error212 });213 ($err:expr $(,)?) => ({214 use $crate::private::kind::*;215 let error = match $err {216 error => (&error).anyhow_kind().new(error),217 };218 error219 });209 ($msg:literal $(,)?) => {210 $crate::private::must_use({211 let error = $crate::private::format_err($crate::private::format_args!($msg));212 error213 })214 };215 ($err:expr $(,)?) => {216 $crate::private::must_use({217 use $crate::private::kind::*;218 let error = match $err {219 error => (&error).anyhow_kind().new(error),220 };221 error222 })223 };224 ($fmt:expr, $($arg:tt)*) => {225 $crate::Error::msg($crate::private::format!($fmt, $($arg)*))226 };227}