Skip to content

Commit 18a61c1

Browse files
authored
Rollup merge of rust-lang#140762 - aDotInTheVoid:popnl, r=GuillaumeGomez
rustdoc-json: Remove newlines from attributes Fixes rust-lang#140689 Not sure if this needs to bump `FORMAT_VERSION` or not. r? `@GuillaumeGomez` cc `@obi1kenobi`
2 parents a2443fe + aeb70c7 commit 18a61c1

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

src/librustdoc/clean/types.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,11 @@ impl Item {
786786
// because it isn't public API.
787787
None
788788
}
789-
_ => Some(rustc_hir_pretty::attribute_to_string(&tcx, attr)),
789+
_ => Some({
790+
let mut s = rustc_hir_pretty::attribute_to_string(&tcx, attr);
791+
assert_eq!(s.pop(), Some('\n'));
792+
s
793+
}),
790794
}
791795
} else if attr.has_any_name(ALLOWED_ATTRIBUTES) {
792796
Some(

tests/rustdoc-json/attrs/automatically_derived.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ impl Default for Manual {
99
}
1010
}
1111

12-
//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Derive" && @.inner.impl.trait.path == "Default")].attrs' '["#[automatically_derived]\n"]'
12+
//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Derive" && @.inner.impl.trait.path == "Default")].attrs' '["#[automatically_derived]"]'
1313
//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Manual" && @.inner.impl.trait.path == "Default")].attrs' '[]'
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ edition: 2021
22
#![no_std]
33

4-
//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]\n"]'
4+
//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]'
55
#[export_name = "altered"]
66
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/export_name_2024.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
// The representation of `#[unsafe(export_name = ..)]` in rustdoc in edition 2024
55
// is still `#[export_name = ..]` without the `unsafe` attribute wrapper.
66

7-
//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]\n"]'
7+
//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]'
88
#[unsafe(export_name = "altered")]
99
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/must_use.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![no_std]
22

3-
//@ is "$.index[?(@.name=='example')].attrs" '["#[must_use]\n"]'
3+
//@ is "$.index[?(@.name=='example')].attrs" '["#[must_use]"]'
44
#[must_use]
55
pub fn example() -> impl Iterator<Item = i64> {}
66

7-
//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]\n"]'
7+
//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]"]'
88
#[must_use = "does nothing if you do not use it"]
99
pub fn explicit_message() -> impl Iterator<Item = i64> {}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ edition: 2021
22
#![no_std]
33

4-
//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]\n"]'
4+
//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]'
55
#[no_mangle]
66
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/no_mangle_2024.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
// The representation of `#[unsafe(no_mangle)]` in rustdoc in edition 2024
55
// is still `#[no_mangle]` without the `unsafe` attribute wrapper.
66

7-
//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]\n"]'
7+
//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]'
88
#[unsafe(no_mangle)]
99
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/non_exhaustive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#![no_std]
22

3-
//@ is "$.index[?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]\n"]'
3+
//@ is "$.index[?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]"]'
44
#[non_exhaustive]
55
pub enum MyEnum {
66
First,
77
}
88

99
pub enum NonExhaustiveVariant {
10-
//@ is "$.index[?(@.name=='Variant')].attrs" '["#[non_exhaustive]\n"]'
10+
//@ is "$.index[?(@.name=='Variant')].attrs" '["#[non_exhaustive]"]'
1111
#[non_exhaustive]
1212
Variant(i64),
1313
}
1414

15-
//@ is "$.index[?(@.name=='MyStruct')].attrs" '["#[non_exhaustive]\n"]'
15+
//@ is "$.index[?(@.name=='MyStruct')].attrs" '["#[non_exhaustive]"]'
1616
#[non_exhaustive]
1717
pub struct MyStruct {
1818
pub x: i64,

tests/rustdoc-json/keyword_private.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
//@ !has "$.index[?(@.name=='match')]"
77
//@ has "$.index[?(@.name=='foo')]"
8-
//@ is "$.index[?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]\n"]'
8+
//@ is "$.index[?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]'
99
//@ is "$.index[?(@.name=='foo')].docs" '"this is a test!"'
1010
#[doc(keyword = "match")]
1111
/// this is a test!
1212
pub mod foo {}
1313

1414
//@ !has "$.index[?(@.name=='break')]"
1515
//@ has "$.index[?(@.name=='bar')]"
16-
//@ is "$.index[?(@.name=='bar')].attrs" '["#[doc(keyword = \"break\")]\n"]'
16+
//@ is "$.index[?(@.name=='bar')].attrs" '["#[doc(keyword = \"break\")]"]'
1717
//@ is "$.index[?(@.name=='bar')].docs" '"hello"'
1818
#[doc(keyword = "break")]
1919
/// hello

0 commit comments

Comments
 (0)