-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Optional lints for optimizing to maximal efficiency #5604
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
Comments
For those lints the Clippy can't tell how something will be optimized in the end, since LLVM is the compiler backend doing those optimizations. That means automatically/dynamically suggesting code that will be optimized in a better, is not in Clippy's scope (If it were, this lint wouldn't exist in the first place, since it would directly be implemented in rustc as a MIR optimization). This is mainly because Clippy does static code analysis, which require static pre-defined rules for code patterns. My point is: What you're asking for already exists and is enabled by default ( |
I just looked back over my comment and now I can see that there's two different ideas that I muddle together in there:
|
Thanks for the more specific issue with examples! For your second point: I also thought about this recently: #5537 (comment) So we could subdivide the |
Inspired by this reddit thread.
I think it would be helpful (and at least one person on reddit agrees with me) if there could be a lint which detects antipatterns which prevent rustc from maximally optimized code (including things like including SIMD instructions, unrolling loops, etc. in the final binary). In the thread and on the page linked from the reddit post, they talk about complicated slice indexing and possible panics as being two common ways for this to happen. There may be other antipatterns we can lint, as well, but none else are mentioned in the thread and I don't know of anything else.
Naturally, this lint should be optional and default to being off, as most sections of code wouldn't need to be that heavily optimized, but this lint could be helpful for people who write code that needs this level of optimization.
The text was updated successfully, but these errors were encountered: