rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.23k stars 12.7k forks source link

`unexpected_cfgs` lint doesn't recognize some standard `cfg`s #124816

Open joshlf opened 6 months ago

joshlf commented 6 months ago

As part of https://github.com/google/zerocopy/pull/1204, I discovered that the unexpected_cfgs lint fires on some standard cfgs that are common in the ecosystem. The two I discovered so far are:

I've had to manually emit directives for these. It's not that onerous, but I could imagine it getting onerous especially for projects that don't already have a build.rs script.

It would be good if the lint could be taught about some of the standard cfgs in the ecosystem to cut down on the noise.

saethlin commented 6 months ago

I submitted https://github.com/rust-lang/rust/pull/124804 to add other well-known cfgs to thev list but it's not clear to me from the lint documentation if there is any interest in accepting additions not used by rustc/cargo, though to my mind accepting cfg(miri) is a clear precedent.

Urgau commented 6 months ago

I think doc_cfg could be replaced by docsrs, it's automatically inserted by docs.rs since https://github.com/rust-lang/docs.rs/pull/2390