Add documentation for allow and cfg attributes.#158070
Conversation
Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @Darksonn (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
| /// Suppress compiler warnings for unused code. | ||
| /// | ||
| /// The `allow` attribute suppresses compiler warnings for unused functions, | ||
| /// variables or imports. |
There was a problem hiding this comment.
It's not for suppressing "warnings for unused code", it's for suppressing any lint (or lint group) (assuming the link in question has not been forbid'den already in the current scope).
dead_code, unused_function, unused_variables and unused_mut you mention below are only 4 out of currently 243 rustc lints and 13 rustc lint groups (ignoring the 819 clippy lints and 10 clippy lint groups, etc.).
It's not just warnings it can be errors, too, since lints can be deny-by-default or set to deny.
| /// | ||
| /// The `allow` attribute suppresses compiler warnings for unused functions, | ||
| /// variables or imports. | ||
| /// |
|
Reminder, once the PR becomes ready for a review, use |
| /// You can also use `cfg` more than once on the same item. The item is only | ||
| /// kept if all the conditions are true, same as combining them with `all(...)`. | ||
| /// | ||
| /// For a check you can use inside a function, see the [`cfg!`] macro. To |
There was a problem hiding this comment.
Since the cfg macro is defined in core and re-exported from std, we could (and probably should) link to the API docs instead of the Reference, using an intra-doc link. IINM you can just remove [`cfg!`]: ../reference/conditional-compilation.html#the-cfg-macro below and the [`cfg!`] should already resolve to https://doc.rust-lang.org/nightly/std/macro.cfg.html 🤔.
There was a problem hiding this comment.
I have addressed it. Please take another look
… and removed cfg link
Added documentation for built-in
allowandcfgattributes using the #[doc(attribute = "...")] mechanism.Part of #157604.
@rustbot r? @GuillaumeGomez