rustc::lint could use some helper functions for working with macros #33177
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
(See #22451 and possibly others)
Currently we have a few functions in clippy
/src/util/mod.rs
to deal with macros. Namely we can check if some span stems from a macro expansion (though that one could need some work), or if some span was expanded by a given macro (by name) somewhere or directly, or if two spans are in the same macro expansion. This is often useful for readability lints which should not be invoked within macro-expanded code (unless perhaps the code before expansion had the same issue, but that is as of yet hard to detect).I think those functions belong in the rustc::lint crate. This would both benefit internal lints and all other lints outside of clippy which could then make use of those helpers.
However, clippy is currently licensed under MPL, so we'd need agreement from the authors (of the respective code lines) to move this code into rustc proper. Also we'll want to look first if those functions are ready to be moved and clean up any technical debt we may have incurred so far.
cc @Manishearth
The text was updated successfully, but these errors were encountered: