Skip to content

Commit 340a934

Browse files
committed
attrs/ is done
1 parent cc155f3 commit 340a934

16 files changed

+64
-55
lines changed

tests/rustdoc-json/attrs/automatically_derived.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ 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]"]'
13-
//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Manual" && @.inner.impl.trait.path == "Default")].attrs' '[]'
12+
//@ arg default [.index[] | select(.inner.impl.trait?.path == "Default")]
13+
//@ jq $default[] | select(.inner.impl.for?.resolved_path?.path == "Derive").attrs == ["#[automatically_derived]"]
14+
//@ jq $default[] | select(.inner.impl.for?.resolved_path?.path == "Manual").attrs == []

tests/rustdoc-json/attrs/cold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
//@ is "$.index[?(@.name=='cold_fn')].attrs" '["#[attr = Cold]"]'
1+
//@ jq .index[] | select(.name == "cold_fn").attrs == ["#[attr = Cold]"]
22
#[cold]
33
pub fn cold_fn() {}
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,46 @@
1-
//@ is "$.index[?(@.name=='not')].attrs" []
2-
//@ is "$.index[?(@.name=='not')].deprecation" null
1+
//@ arg not .index[] | select(.name == "not")
2+
//@ jq $not.attrs == []
3+
//@ jq $not.deprecation == null
34
pub fn not() {}
45

5-
//@ is "$.index[?(@.name=='raw')].attrs" []
6-
//@ is "$.index[?(@.name=='raw')].deprecation" '{"since": null, "note": null}'
6+
//@ arg raw .index[] | select(.name == "raw")
7+
//@ jq $raw.attrs == []
8+
//@ jq $raw.deprecation == {"since": null, "note": null}
79
#[deprecated]
810
pub fn raw() {}
911

10-
//@ is "$.index[?(@.name=='equals_string')].attrs" []
11-
//@ is "$.index[?(@.name=='equals_string')].deprecation" '{"since": null, "note": "here is a reason"}'
12+
//@ arg equals_string .index[] | select(.name == "equals_string")
13+
//@ jq $equals_string.attrs == []
14+
//@ jq $equals_string.deprecation == {"since": null, "note": "here is a reason"}
1215
#[deprecated = "here is a reason"]
1316
pub fn equals_string() {}
1417

15-
//@ is "$.index[?(@.name=='since')].attrs" []
16-
//@ is "$.index[?(@.name=='since')].deprecation" '{"since": "yoinks ago", "note": null}'
18+
//@ arg since .index[] | select(.name == "since")
19+
//@ jq $since.attrs == []
20+
//@ jq $since.deprecation == {"since": "yoinks ago", "note": null}
1721
#[deprecated(since = "yoinks ago")]
1822
pub fn since() {}
1923

20-
//@ is "$.index[?(@.name=='note')].attrs" []
21-
//@ is "$.index[?(@.name=='note')].deprecation" '{"since": null, "note": "7"}'
24+
//@ arg note .index[] | select(.name == "note")
25+
//@ jq $note.attrs == []
26+
//@ jq $note.deprecation == {"since": null, "note": "7"}
2227
#[deprecated(note = "7")]
2328
pub fn note() {}
2429

25-
//@ is "$.index[?(@.name=='since_and_note')].attrs" []
26-
//@ is "$.index[?(@.name=='since_and_note')].deprecation" '{"since": "tomorrow", "note": "sorry"}'
30+
//@ arg since_and_note .index[] | select(.name == "since_and_note")
31+
//@ jq $since_and_note.attrs == []
32+
//@ jq $since_and_note.deprecation == {"since": "tomorrow", "note": "sorry"}
2733
#[deprecated(since = "tomorrow", note = "sorry")]
2834
pub fn since_and_note() {}
2935

30-
//@ is "$.index[?(@.name=='note_and_since')].attrs" []
31-
//@ is "$.index[?(@.name=='note_and_since')].deprecation" '{"since": "a year from tomorrow", "note": "your welcome"}'
36+
//@ arg note_and_since .index[] | select(.name == "note_and_since")
37+
//@ jq $note_and_since.attrs == []
38+
//@ jq $note_and_since.deprecation == {"since": "a year from tomorrow", "note": "your welcome"}
3239
#[deprecated(note = "your welcome", since = "a year from tomorrow")]
3340
pub fn note_and_since() {}
3441

35-
//@ is "$.index[?(@.name=='neither_but_parens')].attrs" []
36-
//@ is "$.index[?(@.name=='neither_but_parens')].deprecation" '{"since": null, "note": null}'
42+
//@ arg neither_but_parens .index[] | select(.name == "neither_but_parens")
43+
//@ jq $neither_but_parens.attrs == []
44+
//@ jq $neither_but_parens.deprecation == {"since": null, "note": null}
3745
#[deprecated()]
3846
pub fn neither_but_parens() {}
Lines changed: 1 addition & 1 deletion
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\"]"]'
4+
//@ jq .index[] | select(.name == "example").attrs == ["#[export_name = \"altered\"]"]
55
#[export_name = "altered"]
66
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/export_name_2024.rs

Lines changed: 1 addition & 1 deletion
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\"]"]'
7+
//@ jq .index[] | select(.name == "example").attrs == ["#[export_name = \"altered\"]"]
88
#[unsafe(export_name = "altered")]
99
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/inline.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[attr = Inline(Hint)]"]'
1+
//@ jq .index[] | select(.name == "just_inline").attrs == ["#[attr = Inline(Hint)]"]
22
#[inline]
33
pub fn just_inline() {}
44

5-
//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[attr = Inline(Always)]"]'
5+
//@ jq .index[] | select(.name == "inline_always").attrs == ["#[attr = Inline(Always)]"]
66
#[inline(always)]
77
pub fn inline_always() {}
88

9-
//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[attr = Inline(Never)]"]'
9+
//@ jq .index[] | select(.name == "inline_never").attrs == ["#[attr = Inline(Never)]"]
1010
#[inline(never)]
1111
pub fn inline_never() {}

tests/rustdoc-json/attrs/must_use.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![no_std]
22

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

7-
//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[attr = MustUse {reason: \"does nothing if you do not use it\"}]"]'
7+
//@ jq .index[] | select(.name == "explicit_message").attrs == ["#[attr = MustUse {reason: \"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> {}
Lines changed: 1 addition & 1 deletion
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]"]'
4+
//@ jq .index[] | select(.name == "example").attrs == ["#[no_mangle]"]
55
#[no_mangle]
66
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/no_mangle_2024.rs

Lines changed: 1 addition & 1 deletion
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]"]'
7+
//@ jq .index[] | select(.name == "example").attrs == ["#[no_mangle]"]
88
#[unsafe(no_mangle)]
99
pub extern "C" fn example() {}

tests/rustdoc-json/attrs/non_exhaustive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#![no_std]
22

3-
//@ is "$.index[?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]"]'
3+
//@ jq .index[] | select(.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]"]'
10+
//@ jq .index[] | select(.name == "Variant").attrs == ["#[non_exhaustive]"]
1111
#[non_exhaustive]
1212
Variant(i64),
1313
}
1414

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

0 commit comments

Comments
 (0)