about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2021-06-05 21:16:19 -0400
committerJoshua Nelson <jyn514@gmail.com>2021-06-05 21:18:20 -0400
commitb8ebf4431e48abe6f1844b80416c11f7b0ccab0c (patch)
tree2122bb059bf1014275cb0173604b961670084eb7
parent34b9932f5c0f519d6b9b9f95f21723142c5dc877 (diff)
downloadrust-b8ebf4431e48abe6f1844b80416c11f7b0ccab0c.tar.gz
rust-b8ebf4431e48abe6f1844b80416c11f7b0ccab0c.zip
Don't fire `invalid_doc_attributes` on `extern crate` items
-rw-r--r--compiler/rustc_passes/src/check_attr.rs2
-rw-r--r--src/test/ui/rustdoc/doc-inline-extern-crate.rs9
-rw-r--r--src/test/ui/rustdoc/doc-inline-extern-crate.stderr13
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
+