Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,10 @@ fn maybe_from_hir_attr(attr: &hir::Attribute, item_id: ItemId, tcx: TyCtxt<'_>)
for attr_span in test_attrs {
// FIXME: This is ugly, remove when `test_attrs` has been ported to new attribute API.
if let Ok(snippet) = source_map.span_to_snippet(*attr_span) {
ret.push(Attribute::Other(format!("#[doc(test(attr({snippet})))")));
ret.push(Attribute::Other(format!("#[doc(test(attr({snippet})))]")));
}
}
toggle_attr(&mut ret, "no_crate_inject", no_crate_inject);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this be toggle_attr with "test(no_crate_inject)"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It absolutely could, and I'll switch it. Two things kept me from it initially. I didn't see any examples of a parenthesized arg to toggle_attr. I also wasn't sure if the // FIXME should apply to this test attr too, and mirroring that block's pattern seemed to rhyme with its FIXME comment better.

I'll change it though!

toggle_attr(&mut ret, "test(no_crate_inject)", no_crate_inject);
return ret;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/rustdoc-json/attrs/no_crate_inject.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Regression test for rustdoc JSON emitting
// `#[doc(no_crate_inject)]` instead of `#[doc(test(no_crate_inject))]`:
// https://github.com/rust-lang/rust/pull/153465

//@ is "$.index[?(@.inner.module.is_crate)].attrs" '[{"other": "#[doc(test(no_crate_inject))]"}]'

#![doc(test(no_crate_inject))]
7 changes: 7 additions & 0 deletions tests/rustdoc-json/attrs/trailing_bracket.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Regression test for rustdoc JSON emitting
// `#[doc(test(attr(deny(rust_2018_idioms))))` without the trailing `]`:
// https://github.com/rust-lang/rust/pull/153465

//@ is "$.index[?(@.inner.module.is_crate)].attrs" '[{"other": "#[doc(test(attr(deny(rust_2018_idioms))))]"}]'

#![doc(test(attr(deny(rust_2018_idioms))))]
Loading