Per-path lint levels in DisallowedPath · Issue #11307 · rust-lang/rust-clippy (original) (raw)

DisallowedPath could gain support for different lint levels for particular paths.

The use case is that a project may want to warn, deny or forbid depending on the method/macro/type/name/... in particular. For instance, a project may want to deny a custom panicking macro and warn about some debugging macros. Assuming -Wdisallowed_macros, they could write:

disallowed-macros = [ "x::dbg", { path = "x::panic", level = "deny" }, ]

These could behave as their own lint for level purposes. However, someone may still want to be able to override them, e.g. to allow or deny all of them, or a few of them. Thus it may be nice to give the user the ability to do so with e.g. -Ddisallowed_macros=x::dbg_foo and -Ddisallowed_macros=* (all, i.e. including both the ones with an explicit level and those without it, since the usual -Ddisallowed_macros applies to the current ones, i.e. those without an explicit level).