# Adding Clippy-like checks to rustc

**URL:** <https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912>\
**Category:** Uncategorized\
**Created:** [August 17, 2020, 10:04pm UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912 "2020-08-17T22:04:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [August 17, 2020, 10:04pm UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912/1 "2020-08-17T22:04:22Z")

</div>

There are some footguns in Rust, like [not checking length returned by `read()`/`write()`](https://internals.rust-lang.org/t/poor-naming-of-read-write-i-o-methods/12685) or [`CString::new().as_ptr()`](https://rust-lang.github.io/rust-clippy/master/#temporary_cstring_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](https://flak.tedunangst.com/post/comparative-unsafety):

> [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?

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [August 17, 2020, 10:31pm UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912/2 "2020-08-17T22:31:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matklad](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/matklad/32/12266_2.png) [@matklad](https://internals.rust-lang.org/u/matklad)\
**Post date:** [August 18, 2020, 6:11am UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912/3 "2020-08-18T06:11:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)\
**Post date:** [August 18, 2020, 10:22am UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912/4 "2020-08-18T10:22:10Z")

</div>

Yes please.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [November 20, 2020, 2:04pm UTC](https://internals.rust-lang.org/t/adding-clippy-like-checks-to-rustc/12912/6 "2020-11-20T14:04:15Z")

</div>

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