Skip to content

Commit a417902

Browse files
committed
[squash before merge] rebase fallout.
1 parent df1d953 commit a417902

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,7 @@ impl Item {
763763
///
764764
/// Only used by the HTML output-format.
765765
fn attributes_without_repr(&self, tcx: TyCtxt<'_>) -> Vec<String> {
766-
const ALLOWED_ATTRIBUTES: &[Symbol] =
767-
&[sym::export_name, sym::link_section, sym::non_exhaustive];
766+
const ALLOWED_ATTRIBUTES: &[Symbol] = &[sym::non_exhaustive];
768767
self.attrs
769768
.other_attrs
770769
.iter()

src/librustdoc/json/conversions.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,8 @@ fn maybe_from_hir_attr(
901901
// and eventually be removed as all attributes gain a strutured representation in
902902
// HIR.
903903
hir::Attribute::Unparsed(_) => {
904-
return Some(if attr.has_name(sym::non_exhaustive) {
905-
Attribute::NonExhaustive
906-
} else if attr.has_name(sym::automatically_derived) {
904+
return Some(if attr.has_name(sym::automatically_derived) {
907905
Attribute::AutomaticallyDerived
908-
} else if attr.has_name(sym::export_name) {
909-
Attribute::ExportName(
910-
attr.value_str().expect("checked by attr validation").to_string(),
911-
)
912906
} else {
913907
// FIXME: We should handle `#[doc(hidden)]` here.
914908
other_attr(tcx, attr)
@@ -927,7 +921,14 @@ fn maybe_from_hir_attr(
927921
tcx,
928922
item_id.as_def_id().expect("all items that could have #[repr] have a DefId"),
929923
),
924+
AK::ExportName { name, span: _ } => Attribute::ExportName(name.to_string()),
925+
AK::LinkSection { name, span: _ } => Attribute::LinkSection(name.to_string()),
926+
930927
AK::NoMangle(_) => Attribute::NoMangle,
928+
AK::NonExhaustive(_) => Attribute::NonExhaustive,
929+
AK::TargetFeature(features, _span) => Attribute::TargetFeature(
930+
features.iter().map(|(feat, _span)| feat.to_string()).collect(),
931+
),
931932

932933
_ => other_attr(tcx, attr),
933934
})

src/rustdoc-json-types/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,14 @@ pub enum Attribute {
214214
NonExhaustive,
215215

216216
/// `#[must_use]`
217-
MustUse {
218-
reason: Option<String>,
219-
},
217+
MustUse { reason: Option<String> },
220218

221219
/// `#[export_name = "name"]`
222220
ExportName(String),
223221

222+
/// `#[link_section = "name"]`
223+
LinkSection(String),
224+
224225
/// `#[automatically_derived]`
225226
AutomaticallyDerived,
226227

@@ -230,6 +231,9 @@ pub enum Attribute {
230231
/// `#[no_mangle]`
231232
NoMangle,
232233

234+
/// #[target_feature(enable = "feature1", enable = "feature2")]
235+
TargetFeature(Vec<String>),
236+
233237
/// Something else.
234238
///
235239
/// Things here are explicitly *not* covered by the [`FORMAT_VERSION`]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ edition: 2021
22
#![no_std]
33

4-
//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]'
4+
//@ count "$.index[?(@.name=='example')].attrs[*]" 1
5+
//@ is "$.index[?(@.name=='example')].attrs[*].link_section" '".text"'
56
#[link_section = ".text"]
67
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/link_section_2024.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Since the 2024 edition the link_section attribute must use the unsafe qualification.
55
// However, the unsafe qualification is not shown by rustdoc.
66

7-
//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]'
7+
//@ count "$.index[?(@.name=='example')].attrs[*]" 1
8+
//@ is "$.index[?(@.name=='example')].attrs[*].link_section" '".text"'
89
#[unsafe(link_section = ".text")]
910
pub extern "C" fn example() {}
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
//@ only-x86_64
2-
3-
//@ is "$.index[?(@.name=='test1')].attrs" '["#[target_feature(enable=\"avx\")]"]'
1+
//@ count "$.index[?(@.name=='test1')].attrs[*]" 1
2+
//@ is "$.index[?(@.name=='test1')].attrs[*].target_feature" '["avx"]'
43
#[target_feature(enable = "avx")]
54
pub fn test1() {}
65

7-
//@ is "$.index[?(@.name=='test2')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]'
6+
//@ count "$.index[?(@.name=='test2')].attrs[*]" 1
7+
//@ is "$.index[?(@.name=='test2')].attrs[*].target_feature" '["avx", "avx2"]'
88
#[target_feature(enable = "avx,avx2")]
99
pub fn test2() {}
1010

11-
//@ is "$.index[?(@.name=='test3')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]'
11+
//@ count "$.index[?(@.name=='test3')].attrs[*]" 1
12+
//@ is "$.index[?(@.name=='test3')].attrs[*].target_feature" '["avx", "avx2"]'
1213
#[target_feature(enable = "avx", enable = "avx2")]
1314
pub fn test3() {}
1415

15-
//@ is "$.index[?(@.name=='test4')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\", enable=\"avx512f\")]"]'
16+
//@ count "$.index[?(@.name=='test4')].attrs[*]" 1
17+
//@ is "$.index[?(@.name=='test4')].attrs[*].target_feature" '["avx", "avx2", "avx512f"]'
1618
#[target_feature(enable = "avx", enable = "avx2,avx512f")]
1719
pub fn test4() {}
20+
21+
//@ count "$.index[?(@.name=='test5')].attrs[*]" 1
22+
//@ is "$.index[?(@.name=='test5')].attrs[*].target_feature" '["avx", "avx2"]'
23+
#[target_feature(enable = "avx")]
24+
#[target_feature(enable = "avx2")]
25+
pub fn test5() {}

0 commit comments

Comments
 (0)