Skip to content

Commit

Permalink
Don't fire invalid_doc_attributes on extern crate items
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Jun 6, 2021
1 parent 34b9932 commit b8ebf44
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/rustdoc/doc-inline-extern-crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[doc(inline)]
//~^ ERROR conflicting
#[doc(no_inline)]
pub extern crate core;

// no warning
pub extern crate alloc;

fn main() {}
13 changes: 13 additions & 0 deletions src/test/ui/rustdoc/doc-inline-extern-crate.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b8ebf44

Please sign in to comment.