Open llogiq opened 9 years ago
Hi
I loved the idea and I've been working on this recently, it's not finished yet but I think it's ready to talk about it and it's usable.
I think it's much bigger than any lint in clippy, it also needs a database, an optional configuration file and can optionally use an external program (herbie-inout
) too so I'm not just making a PR here, but if you think it could be integrated that'd be awesome.
I'm fine with this being a separate lint, really :smile: . I have a defunct project, rust-Wall
, which is meant to reexport lints from basically all the lint crates, except so far there is only one with universally-useful lints (clippy), so it never got used. We could reexport there and revive it.
Why does it need a database?
The database contains cached expression replacements eg. (a*a + b*b).sqrt()
→ a.hypot(b)
. It's required because Herbie is too slow to re-analyze every expressions every time. Also Herbie is quite difficult to install and requires a specific, not up-to-date, version of some esoteric language I forgot the name of. I've had to install it in docker. But with a pre-filled database, the installation is not required. The database format is the same as for Haskell's plugin, so they can be shared.
Nice to hear about rust-Wall
, it's a shame there are no more lints (or not, maybe every one is just collaborating here :smile:).
We could probably use rust-phf to in-memory that database? figure out a hashable representation for it and go!
Everyone is just collaborating here :smile: When I created rust-Wall clippy was small and I didn't expect it to be the One True home for lints
I think we should keep the database, using rust-phf
we could not cache new expression replacements as they are discovered by Herbie as it's a compile time thing.
Isn't the discovery thing slow? Perhaps we could build up a good database by merging all the existing Haskell-Herbie stuff and running the slow rust-herbie on a ton of crates in the ecosystem?
Currently I've only used the database from Haskell-Herbie but I plan to run it on “a ton of crates in the ecosystem” of course :smile: If you guys have ideas of crates I've opened an issue to list them: https://github.com/mcarton/rust-herbie-lint/issues/2.
fyi you're getting some well-deserved publicity here :smile:
I'd like this lint to be available in clippy; otherwise it just doesn't get used.
Are there any other lints that could benefit from a dependency onHerbie
or Z3
? Maybe having these as dependencies won't pay off initially, but as more lints use them the cost can be amortized over time.
Something along the lines of Herbie for Haskell, but without the auto-fixing – perhaps we can port the transformations to give (very) good suggestions.