So this is funny, the query `tcx.module_children` was top 3 in most time consuming functions in Clippy, it was being called 24384 times in tokio. "Unacceptable!" I thought. Digging a bit around, turns out that `clippy::strlen_on_c_strings` was calling for `get_def_path` via `match_libc_symbol`. This query pretty-prints things and performs some analysis. Yes, we were running early lint checks to see if symbols were from `libc`. I don't really trust callgrind when it says I've turn 81 billion instructions into like 10 million. So I benchmarked this the good ol' "compiling 20 times without incr" method and it went from 0.31s-0.45s to 0.25s constistently. (Profiled, and "benchmarked") on tokio. What I can get behind is via `strlen_on_c_strings` changing from 31 million instructions into 76k. 🎉 🥳 changelog: [`strlen_on_c_strings`]: Optimize it by 99.75% |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
clippy-utils
Helpful tools for writing lints, provided as they are used in Clippy.
Usage
This crate is only guaranteed to build with this nightly toolchain:
nightly-2025-05-31
To use clippy-utils in your lint, add the following to your Cargo.toml:
clippy_utils = "0.1.XY"
XY is the version of the nightly toolchain above and can be determined with rustc +nightly-YYYY-MM-DD -V.
⚠️ Stability ⚠️
No stability guarantees are made for this crate! Use at your own risk.
Function signatures can change or be removed without replacement without any prior notice.
LICENSE
Copyright 2014-2025 The Rust Project Developers
Licensed under the Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <https://opensource.org/licenses/MIT>, at your option. Files in the project may not be copied, modified, or distributed except according to those terms.