Skip to content
Myr

Remove workaround for nonstring literals

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

Stringifying a non-string $:literal for passing into the format_args call is incompatible with format args capture: "to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro". error: there is no argument named `var`" --> src/main.rs:3:26 | 3 | let _ = format_args!(concat!("{var}")); | ^^^^^^^^^^^^^^^^ | = note: did you intend to capture a variable `var` from the surrounding scope? = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro

authored by David Tolnay · committed by David Tolnay · parent 941d3d6 · Browse files · 1 file+1 added−1 removed
This commit

State

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

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:src/macros.rs+1 added-1 removed
166 unmodified lines
167/// ```168#[macro_export]169macro_rules! anyhow {170 ($msg:literal $(,)?) => {171 $crate::private::format_err($msg, $crate::private::format_args!($crate::private::concat!($msg)))171 $crate::private::format_err($msg, $crate::private::format_args!($msg))172 };173 ($err:expr $(,)?) => ({174 use $crate::private::kind::*;175 match $err {
7 unmodified lines