rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.51k stars 1.55k forks source link

nonminimal_bool can produce minimal but not human readable expressions #3141

Open oli-obk opened 6 years ago

oli-obk commented 6 years ago

E.g. !a && (b || c) || a && (d || e) || !a && f produces

But a human would rather have

a && (d || e) || !a && (b || c || f)

which is three operators deep, and our algorithm always produces expressions two operators deep.

There must be some scientific papers, theses or blog posts about different models of "simple" boolean expressions. Lets find some and implement them.

kazcw commented 6 years ago

For this particular example, I think the best representation would be:

if a { d || e } else { b || c || f }

flip1995 commented 6 years ago

Context: https://github.com/rust-lang-nursery/rust-clippy/pull/3129#discussion_r215662788