diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-06 19:11:24 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-06 19:11:24 +0900 |
| commit | 19433c44bde0dd6ed674bd03f1cefbfc2f95c676 (patch) | |
| tree | 0321b1e5b1d8b8175b6f59613de38cb524eade38 | |
| parent | 2f0a8556a9add078c3ecc9d748e9ec820817fd42 (diff) | |
| parent | b8ebf4431e48abe6f1844b80416c11f7b0ccab0c (diff) | |
| download | rust-19433c44bde0dd6ed674bd03f1cefbfc2f95c676.tar.gz rust-19433c44bde0dd6ed674bd03f1cefbfc2f95c676.zip | |
Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov
Don't fire `invalid_doc_attributes` on `extern crate` items Fixes https://github.com/rust-lang/rust/issues/86046.
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rustdoc/doc-inline-extern-crate.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/rustdoc/doc-inline-extern-crate.stderr | 13 |
3 files changed, 23 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 91b64611511..b18ef302962 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -577,7 +577,7 @@ impl CheckAttrVisitor<'tcx> { target: Target, specified_inline: &mut Option<(bool, Span)>, ) -> bool { - if target == Target::Use { + if target == Target::Use || target == Target::ExternCrate { let do_inline = meta.name_or_empty() == sym::inline; if let Some((prev_inline, prev_span)) = *specified_inline { if do_inline != prev_inline { diff --git a/src/test/ui/rustdoc/doc-inline-extern-crate.rs b/src/test/ui/rustdoc/doc-inline-extern-crate.rs new file mode 100644 index 00000000000..0eb4c149060 --- /dev/null +++ b/src/test/ui/rustdoc/doc-inline-extern-crate.rs @@ -0,0 +1,9 @@ +#[doc(inline)] +//~^ ERROR conflicting +#[doc(no_inline)] +pub extern crate core; + +// no warning +pub extern crate alloc; + +fn main() {} diff --git a/src/test/ui/rustdoc/doc-inline-extern-crate.stderr b/src/test/ui/rustdoc/doc-inline-extern-crate.stderr new file mode 100644 index 00000000000..41518295b12 --- /dev/null +++ b/src/test/ui/rustdoc/doc-inline-extern-crate.stderr @@ -0,0 +1,13 @@ +error: conflicting doc inlining attributes + --> $DIR/doc-inline-extern-crate.rs:1:7 + | +LL | #[doc(inline)] + | ^^^^^^ this attribute... +LL | +LL | #[doc(no_inline)] + | ^^^^^^^^^ ...conflicts with this attribute + | + = help: remove one of the conflicting attributes + +error: aborting due to previous error + |
