Adding Clippy-like checks to rustc

There are some footguns in Rust, like not checking length returned by read()/write() or CString::new().as_ptr() giving a dangling pointer.

There's no proper language feature to catch these problems, so they've been relegated to Clippy. This approach doesn't work well:

[Clippy] also complains about a million other things, including the fact that I write numbers as 1000000 and not 1_000_000. There's something about errors and warnings, but some of my other stylistic atrocities like single iteration loops are marked as errors as well. I used it for a while, but generally found it too tiresome.

If there's an error which is a clear cut bug, I think it should be reported by an error detecting tool, not a linter.

Could some of the most serious Clippy lints be moved to rustc itself? So that they're always run, and always watch out for these bugs?

13 Likes

This is the latest I remember on this conversation: https://github.com/rust-lang/rust/issues/53224#issuecomment-572809328

2 Likes

For CString in particular, someone should “just” send a PR already :slight_smile:

5 Likes

Yes please.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.