Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,21 @@ pub struct DocAttribute {
pub no_crate_inject: Option<Span>,
}

impl DocAttribute {
/// Returns `true` if contains `doc(inline)` and doesn't contain `doc(no_inline)`.
pub fn is_inline(&self) -> bool {
let mut is_no_inline = false;
let mut is_inline = false;
for (inline, _) in &self.inline {
match inline {
DocInline::Inline => is_inline = true,
DocInline::NoInline => is_no_inline = true,
}
}
is_inline && !is_no_inline
}
}

/// Represents parsed *built-in* inert attributes.
///
/// ## Overview
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ fn analyze_attr(attr: &hir::Attribute, state: &mut AnalyzeAttrState<'_>) -> bool
} else if let hir::Attribute::Parsed(AttributeKind::Doc(d)) = attr {
// If this is a `doc` attribute that doesn't have anything except maybe `inline` (as in
// `#[doc(inline)]`), then we can remove it. It won't be inlinable in downstream crates.
if d.inline.is_empty() {
if !d.is_inline() {
should_encode = true;
if d.hidden.is_some() {
state.is_doc_hidden = true;
Expand Down
Loading