Rename to inline_attr
and use if-let to extract NestedMetaItem
This commit is contained in:
parent
715c19e75e
commit
681cccad57
@ -2163,19 +2163,20 @@ fn clean_use_statement(
|
|||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
let doc_meta_item = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
|
let inline_attr = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
|
||||||
let please_inline = doc_meta_item.is_some();
|
|
||||||
let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore;
|
let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore;
|
||||||
|
|
||||||
if pub_underscore && please_inline {
|
if pub_underscore {
|
||||||
rustc_errors::struct_span_err!(
|
if let Some(ref inline) = inline_attr {
|
||||||
cx.tcx.sess,
|
rustc_errors::struct_span_err!(
|
||||||
doc_meta_item.unwrap().span(),
|
cx.tcx.sess,
|
||||||
E0780,
|
inline.span(),
|
||||||
"anonymous imports cannot be inlined"
|
E0780,
|
||||||
)
|
"anonymous imports cannot be inlined"
|
||||||
.span_label(import.span, "anonymous import")
|
)
|
||||||
.emit();
|
.span_label(import.span, "anonymous import")
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We consider inlining the documentation of `pub use` statements, but we
|
// We consider inlining the documentation of `pub use` statements, but we
|
||||||
@ -2208,7 +2209,7 @@ fn clean_use_statement(
|
|||||||
}
|
}
|
||||||
Import::new_glob(resolve_use_source(cx, path), true)
|
Import::new_glob(resolve_use_source(cx, path), true)
|
||||||
} else {
|
} else {
|
||||||
if !please_inline {
|
if inline_attr.is_none() {
|
||||||
if let Res::Def(DefKind::Mod, did) = path.res {
|
if let Res::Def(DefKind::Mod, did) = path.res {
|
||||||
if !did.is_local() && did.index == CRATE_DEF_INDEX {
|
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
|
// if we're `pub use`ing an extern crate root, don't inline it unless we
|
||||||
|
Loading…
Reference in New Issue
Block a user