Make cfg imply doc(cfg) by GuillaumeGomez · Pull Request #89596 · rust-lang/rust...
source link: https://github.com/rust-lang/rust/pull/89596
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):
hidden_cfg
is now in theCache
instead ofDocContext
becausecfg
information isn't stored anymore onclean::Attributes
type but instead computed on-demand, so we need this information in later parts of rustdoc.- I removed the
bool_to_options
feature (which makes the code a bit simpler to read forSingleExt
trait implementation. - I updated the version for the feature.
There is only one thing I couldn't figure out: this comment
I think I'll likely scrap the whole
SingleExt
extension trait as the diagnostics for 0 and >1 items should be different.
How/why should they differ?
EDIT: this part has been solved, the current code was fine, just needed a little simplification.
Original PR description:
This is only active when the doc_cfg
feature is active.
The implicit cfg can be overridden via #[doc(cfg(...))]
, so e.g. to hide a #[cfg]
you can use something like:
#[cfg(unix)] #[doc(cfg(all()))] pub struct Unix;
By adding #![doc(cfg_hide(foobar))]
to the crate attributes the cfg #[cfg(foobar)]
(and only that exact cfg) will not be implicitly treated as a doc(cfg)
to render a message in the documentation.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK