-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: loadable lints #89
Conversation
My first concern is that different types of lints may want to run at different phases of compilation. We could probably extend the #[phase(foo)] stuff to make this work, but we should make sure that what we choose right now is the right name so we don't have to make all the existing ones rename, if possible. For example, some lints may want to run before macro expansion, after macro expansion, after identifiers are resolved, before or after borrow checking.... (I'm not an expert in rustc internals, so I'm not sure entirely how phases are organized; my examples may be bad) |
I don't have time to read right now, but:
|
|
||
Do we provide guarantees about visit order for a lint, or the order of multiple lints defined in the same crate? Some lints may require multiple passes. | ||
|
||
Should `rustc -W help` show user-defined lints? It can't unless a crate filename is also given. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should. Without a crate filename, it would look like it does today. With a crate filename it could then have a second block of lints that will be used when compiling that crate.
@mcpherrinm: I don't think
|
My second concern is that if you have a lot of lints, calling check_item (or check_expr or check_fn or whatever) for N lints on M nodes could be a lot of extra work. Some sort of more intelligent invocation of lints may be of interest. But that's a problem for the future, since we'll certainly want the option of examining every expr or whatever. I'm not sure what that looks like right now: CSS selectors are what pop into my head right now. |
I am a huge fan of loadable lints. I agree with @huonw, I'd love to see lints be able to run at different times, so they can flag things earlier. I'm also concerned that there's no way to require the use of a lint when using a particular library. For my rust-lua use-case, I need to require the lint to be used, and set it to forbid (so it can't be overridden). This isn't a hard requirement, because I have a macro that's used to define the exported Rust functions and those functions are where I really need this lint. So if the user has the macro, they'll presumably have the lint too (unless we split |
The only way I can think of to deal with that, though, is to have some sort of crate attribute that requires clients of the crate to pull in its lints too, and not just link against it. |
I was talking with @lifthrasiir about inferring phase for an I think it makes sense to design phase inference and mandatory lints at the same time. @kballard: A mandatory, always-forbid lint seems really aggressive, when the user can still do arbitrary bad things inside |
Actually that raises another interesting possibility: Lint levels like
This seems orthogonal to loadable lints, but it might become much more useful in that context. |
@kmcallister The particular lint I want doesn't actually make sense to have configurable levels. If you need to do something unsafe, the library already provides a facility to get an |
Discussed at https://github.com/rust-lang/rust/wiki/Meeting-weekly-2014-06-17#rfc-pr-89-loadable-lints-httpsgithubcomrust-langrfcspull89-. There continues to be wide discomfort about the user-visible mechanisms involved in our plugin system, but agreement that we want loadable lints, and begrudging acceptance that we should continue down this feature-gated path to get the functionality we need. Accepted as RFC 29. |
No description provided.