Skip to content

Commit af6b419

Browse files
authored
Unrolled build for #153465
Rollup merge of #153465 - obi1kenobi:pg/trailing-bracket-fix, r=aDotInTheVoid Fix incorrect rustdoc JSON representation of `#[doc(test(..))]` attrs. Attributes like `#[doc(test(attr(deny(rust_2018_idioms))))]` are accidentally emitted without the final `]`. Also, the `#[doc(test(no_crate_inject))]` attribute is mistakenly emitted as `#[doc(no_crate_inject)]` — note the missing `test` wrapper. This PR adds the missing `]` and fixes the `no_crate_inject`, and adds regression tests for both. Thanks to the folks working on `tonic` and `pyo3` for reporting a `cargo-semver-checks` crash on Rust 1.94 in their projects, which led me to finding this bug. Refs: - https://github.com/hyperium/tonic/actions/runs/22732044107/job/65957306230?pr=2536 - https://github.com/PyO3/pyo3/actions/runs/22745106403/job/65967167797 - obi1kenobi/cargo-semver-checks#1590 r? @aDotInTheVoid
2 parents 085c58f + d3149ca commit af6b419

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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)