Skip to content

Commit

Permalink
Rename to inline_attr and use if-let to extract NestedMetaItem
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed Feb 12, 2021
1 parent 715c19e commit 681ccca
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,19 +2163,20 @@ fn clean_use_statement(
return Vec::new();
}

let doc_meta_item = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
let please_inline = doc_meta_item.is_some();
let inline_attr = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore;

if pub_underscore && please_inline {
rustc_errors::struct_span_err!(
cx.tcx.sess,
doc_meta_item.unwrap().span(),
E0780,
"anonymous imports cannot be inlined"
)
.span_label(import.span, "anonymous import")
.emit();
if pub_underscore {
if let Some(ref inline) = inline_attr {
rustc_errors::struct_span_err!(
cx.tcx.sess,
inline.span(),
E0780,
"anonymous imports cannot be inlined"
)
.span_label(import.span, "anonymous import")
.emit();
}
}

// We consider inlining the documentation of `pub use` statements, but we
Expand Down Expand Up @@ -2208,7 +2209,7 @@ fn clean_use_statement(
}
Import::new_glob(resolve_use_source(cx, path), true)
} else {
if !please_inline {
if inline_attr.is_none() {
if let Res::Def(DefKind::Mod, did) = path.res {
if !did.is_local() && did.index == CRATE_DEF_INDEX {
// if we're `pub use`ing an extern crate root, don't inline it unless we
Expand Down

0 comments on commit 681ccca

Please sign in to comment.