4 ms·
Maybe I'm missing something but this sounds less like a linter and more like an optimization pass?
by niccaluim 10y ago
Maybe I'm missing something but this sounds less like a linter and more like an optimization pass?
- chrismorgan 10y agoIt’s not about the optimising compiler, but rather about suggestions on more advanced refactorings and things like that. It’s a pass for the linter which produces the information that can be used to produce optimisation lints.
- willvarfar 10y agoIt would be a suitable "analysis pass" in LLVM.
- llogiq 10y agoYes, but Rust lints cannot currently access LLVM pass information.
- Manishearth 10y agoIt's half a lint. It collects metadata about the code, making it easier to do whole-program analysis. Most of the lints we have so far do at most whole-function analysis. The other half, to be written, would use the metadata to lint things. "Can never panic" is one such lint that could be written with this for example. As an optimization pass it would have to actually change the generated code. It doesn't affect that (nor does Rust's plugin lint functionality; which it uses; let you do that)
- sievebrain 10y agoThis sounds like a component of the type of tool normally called a static analysis engine. "Lint" to me implies more of a lightweight tool that complains about tabs vs spaces and things like that.
- llogiq 10y agoI just call it a lint because it uses the rustic::lint API. And I posited that such analysis belongs in the compiler. However, lints no longer need to be lightweight; I've seen full-program analysis passes called lints. And in rust, lints usually don't complain about tabs/spaces (though we could write one), but rather certain idioms which are exacerbating readability, flexibility, performance or any combination of the above.
- Manishearth 10y agoThe general term lint refers to things that catch possible bugs. http://github.com/manishearth/rust-clippy/ http://github.com/manishearth/rust-clippy/ contains tons of lints which are much more powerful than just tabs vs spaces. Many catch code style things, but some of them also catch possible bugs. The example I gave of "does not panic" isn't really a lint, more of a restriction -- a static analysis pass that helps catch things which might not usually be a problem, but are a problem for your specific use case (so off by default). But there are lints as well which could benefit from the nsa lint backend.
- melloc 10y agoThings that complain about tabs vs spaces and other code layout concerns are style checkers. Linters complain about the actual content of the program, and enforce certain behavior. For example, warning you about unused functions, parameters, and variables, warning on duplicate fields in JavaScript objects, complaining about using parameter lists in C, etc.