You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(format_args_capture)]fnmain(){
env_logger::init();let x = 0;
log::error!("{x}");}
The above program logs {x}without unused-variables warning because log! treats single argument specially and uses __log_format_args! to validate the argument:
// ensure that $message is a valid format string literal
let _ = __log_format_args!($message);
I don't understand why log! treats single argument specially. The __private_api_log code path and __private_api_log_lit path should do the same thing (both of them construct fmt::Arguments):
If the (redundant?) single argument special treatment is removed, #![feature(format_args_capture)] will be supported. That is not a breaking change because log! already uses __log_format_args! to validate the argument (edit: not totally true → #407).
I'd like to help if this request is accepted.
The text was updated successfully, but these errors were encountered:
That special case existed to minimize the amount of code generated, but it's not compatible with format_args_capture as you pointed out. It should just be removed.
It would be great if this crate supports
#![feature(format_args_capture)]
. It currently does not (playground):The above program logs
{x}
withoutunused-variables
warning becauselog!
treats single argument specially and uses__log_format_args!
to validate the argument:log/src/macros.rs
Lines 35 to 36 in 1cd39c0
I don't understand why
log!
treats single argument specially. The__private_api_log
code path and__private_api_log_lit
path should do the same thing (both of them constructfmt::Arguments
):log/src/lib.rs
Line 1481 in 1cd39c0
log/src/lib.rs
Line 1462 in 1cd39c0
If the (redundant?) single argument special treatment is removed,
#![feature(format_args_capture)]
will be supported.That is not a breaking change because(edit: not totally true → #407).log!
already uses__log_format_args!
to validate the argumentI'd like to help if this request is accepted.
The text was updated successfully, but these errors were encountered: