Oh, and another open question (that very much fits into this thread): I sometimes come across patterns where we want lints that subsume each other. E.g. (not yet written) unicode should subsume zero_width_space.
So, I want the following behavior:
-
#[warn(unicode, zero_width_space)] is the same as #[warn(unicode)].
-
#[deny(unicode)] #[warn(zero_width_space)] should only generate the unicode error, not warn of the zero width space in addition.
-
#[warn(unicode) #[deny(zero_width_space)] should warn on all unicode characters and also deny zero-width space characters. In this case, as the unicode spans fully contain the zero-width-space spans, only warn if both spans aren’t equal.
However, this is not at all trivial to write.
Another example: Let’s say I want a string_add and a string_add_assign lint (where the former lints all + on Strings, while the latter only lints x = x + .. where x is a String). Obviously the former subsumes the latter (because it matches all its occurrences), but a) the resulting span is smaller and b) there is no simple way to find out if the outer expression is a self-assignment when visiting the inner BinaryExpr (x + ..).
This is all quite complex. Perhaps we could add some supporting code in the compiler?