Description
Given a bar
library crate with a global #![allow(non_snake_case)]
and a macro that generates functions with a given name, with or without a local #[allow(non_snake_case)]
:
#![allow(non_snake_case)]
#[macro_export]
macro_rules! snakes_on_a_case {
(global_allow $name:ident) => {
pub fn $name() {}
};
(local_allow $name:ident) => {
#[allow(non_snake_case)]
pub fn $name() {}
};
}
If that crate is used by another crate to generate non-snake-case-named functions:
use bar::*;
snakes_on_a_case!(local_allow ANonSnakeCaseName);
snakes_on_a_case!(global_allow AnotherNonSnakeCaseName);
fn main() {
ANonSnakeCaseName();
AnotherNonSnakeCaseName();
}
Then nightly rustc since 2019-01-15 (rustc 1.33.0-nightly (03acbd71c 2019-01-14)
) will warn that functions generated by the macro without the local #[allow(non_snake_case)]
should have a snake case name:
warning: function `AnotherNonSnakeCaseName` should have a snake case name
--> src/main.rs:4:32
|
4 | snakes_on_a_case!(global_allow AnotherNonSnakeCaseName);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `another_non_snake_case_name`
|
= note: #[warn(non_snake_case)] on by default
Whereas nightly rustc on 2019-01-14 (rustc 1.33.0-nightly (2fadb0a16 2019-01-13)
) doesn't emit this warning.
Here's the comparison between the two nightly builds. To my untrained eye, @euclio's 7c0d145 (improve non_snake_case diagnostics
) and @bors's 1d029c6 (Auto merge of #57387 - euclio:nonstandard-style-suggestions
) look potentially related.
Note: I can't reproduce if the macro is in a module within the same crate that uses it, only if it's exported from a different crate (thus complicating the reduction of the test case to a single code snippet).