Skip to content

Commit d3149ca

Browse files
committed
Fix incorrect rustdoc JSON representation of #[doc(test(..))] attrs.
1 parent 69370dc commit d3149ca

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/librustdoc/json/conversions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,10 @@ fn maybe_from_hir_attr(attr: &hir::Attribute, item_id: ItemId, tcx: TyCtxt<'_>)
10411041
for attr_span in test_attrs {
10421042
// FIXME: This is ugly, remove when `test_attrs` has been ported to new attribute API.
10431043
if let Ok(snippet) = source_map.span_to_snippet(*attr_span) {
1044-
ret.push(Attribute::Other(format!("#[doc(test(attr({snippet})))")));
1044+
ret.push(Attribute::Other(format!("#[doc(test(attr({snippet})))]")));
10451045
}
10461046
}
1047-
toggle_attr(&mut ret, "no_crate_inject", no_crate_inject);
1047+
toggle_attr(&mut ret, "test(no_crate_inject)", no_crate_inject);
10481048
return ret;
10491049
}
10501050

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for rustdoc JSON emitting
2+
// `#[doc(no_crate_inject)]` instead of `#[doc(test(no_crate_inject))]`:
3+
// https://github.com/rust-lang/rust/pull/153465
4+
5+
//@ is "$.index[?(@.inner.module.is_crate)].attrs" '[{"other": "#[doc(test(no_crate_inject))]"}]'
6+
7+
#![doc(test(no_crate_inject))]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for rustdoc JSON emitting
2+
// `#[doc(test(attr(deny(rust_2018_idioms))))` without the trailing `]`:
3+
// https://github.com/rust-lang/rust/pull/153465
4+
5+
//@ is "$.index[?(@.inner.module.is_crate)].attrs" '[{"other": "#[doc(test(attr(deny(rust_2018_idioms))))]"}]'
6+
7+
#![doc(test(attr(deny(rust_2018_idioms))))]

0 commit comments

Comments
 (0)