This mirrors a similar commit fe073054a0999d1bb238cb0293757741e95b3588
that changed output for Level, it seems sensible if the user wishes to
output the logging filter level to afford the same formatting choices.
The log! macro matches part of its arguments as $($arg:tt)+, but the other
macros match it as $($arg:tt)*. That means if a user calls error!() or any of
the other macros with an empty argument, it successfully matches the macro rules
of the first macro they called but then turns into an invalid call to log!,
leading to a confusing error message.
This PR uses $($arg:tt)+ consistently to match arguments.
Example:
use log::error;
fn main() {
error!();
}
Before:
error: expected identifier, found `,`
--> src/main.rs:4:5
|
4 | error!();
| ^^^^^^^^^
| |
| expected identifier
| help: remove this comma
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
After:
error: unexpected end of macro invocation
--> src/main.rs:4:5
|
4 | error!();
| ^^^^^^^^^ missing tokens in macro arguments
ATOMIC_USIZE_INIT was deprecated in rust 1.34. Silence the deprecation
warning until our MSRV >= 1.24, where we can use the replacement const
fn `AtomicUsize::new`
github: fixes#320
This fixes the following error when using Rust 2018 style macro imports.
use log::info;
fn main() {
info!("...");
}
error: cannot find macro `log!` in this scope
--> src/main.rs:4:5
|
4 | info!("...");
| ^^^^^^^^^^^^^
The `local_inner_macros` modifier resolves all macro invocations made
from within that macro as macros in the same crate. So if `info!`
expands to an invocation of `log!` then this would be resolved as
`$crate::log!` rather than requiring the caller to have `log` in scope.
The attribute is ignored by pre-2018 compilers so log will continue to
work as normal with #[macro_use].
In the future when dropping compatibility with pre-2018 compilers we can
remove the `local_inner_macros` modifier and use our own explicit
`$crate::` prefixes on invocations of local macros.