When I try to suppress a warning about the module name, like this:
#[allow(non_snake_case)] // abbreviation
pub mod HSM;
it has the effect of disabling the warning for the entire module (all the functions and variables inside it).
That's not what I want, I only want it to stop complaining about HSM.
How can I do it?
mod hidden {
pub mod hsm;
}
pub use hidden::hsm as HSM;
and I think that would by-default show HSM as the defining module in documentation.
But if you want to do this via reƫxports, it'd be easier to just do
#[doc(hidden)] pub mod hsm;
#[doc(inline)] pub use hsm as HSM;
to get almost the same effect.
However, it's worth noting that the canonical path used by e.g. error messages (and name mangling) will still use the actual definition module (at least until name shortening heuristics get implemented). But there's a simpler solution that we've overlooked...
#[allow(nonstandard_style)]
mod HSM {
#![warn(nonstandard_style)]
}
Maybe not the prettiest thing to have to reƫnable the lint (and it won't respect e.g. a #[deny(nonstandard_style)] at the top level), but it functions without weird reƫxports and gives the expected canonical names.
I tried that too (with non_snake_case) but both the outer and inner attribute attach to the module/thing-more-generally directly. That is, the inner attribute doesn't mean "put this on everything in here" it means "put it directly on the thing I'm inside", and in both cases it applies recursively. So the code as given will still warn for mod HSM itself.
I didn't find a way around this but didn't try excessively after figuring that much out. I didn't read ECMA-335 either. So it's still possible there is some way.
Thank you both for trying to help!
I thought I've overlooked some obvious way of specifying attribute target.
But since there is none, I've simply renamed the module to lowercase.
It's unfortunate, but not the end of the world. And using clever renaming tricks certainly does not worth the added complexity.
I've found it best to just give in and follow the Rust naming conventions. Trying to preserve uppercase in acronyms is a hopeless quest; what do you do when the acronym is itself an acronym of other acronyms?