Skip to content

Commit a4c0173

Browse files
authored
Rollup merge of #138763 - aDotInTheVoid:two-years-later, r=GuillaumeGomez
jsondocck: Replace `jsonpath_lib` with `jsonpath-rust` The current jsonpath implementation we use isn't spec-compliant, and is buggy. See freestrings/jsonpath#91 To solve it, it's replaced with https://github.com/besok/jsonpath-rust. This is spec-compiant, and doesn't have a really awkward bug we need to always dance around. Unfortunately, this requires rewriting almost every test, as the behaviour of `[?(```@`,``` which is *extremely* common was changed. (But the new behaviour makes way more sense, and isn't buggy with tripply nested selectors) Unblocks #110406. Makes #100515 much easier as we don't need to explain the broken JSONPath implementation Best reviewed commit-by-commit. The first does the replacement. The next two rewrite the test-suite mechanically. The last rewrites the test-suite by hand. r? ```@GuillaumeGomez```
2 parents fb09bd5 + 13335e3 commit a4c0173

File tree

155 files changed

+1259
-1192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1259
-1192
lines changed

Cargo.lock

+59-7
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ version = "0.1.0"
19251925
dependencies = [
19261926
"fs-err",
19271927
"getopts",
1928-
"jsonpath_lib",
1928+
"jsonpath-rust",
19291929
"regex",
19301930
"serde_json",
19311931
"shlex",
@@ -1945,14 +1945,16 @@ dependencies = [
19451945
]
19461946

19471947
[[package]]
1948-
name = "jsonpath_lib"
1949-
version = "0.3.0"
1948+
name = "jsonpath-rust"
1949+
version = "1.0.0"
19501950
source = "registry+https://github.com/rust-lang/crates.io-index"
1951-
checksum = "eaa63191d68230cccb81c5aa23abd53ed64d83337cacbb25a7b8c7979523774f"
1951+
checksum = "9b0231bb404a6cd6c8f0ab41b907049063a089fc02aa7636cc5cd9a4d87364c9"
19521952
dependencies = [
1953-
"log",
1954-
"serde",
1953+
"pest",
1954+
"pest_derive",
1955+
"regex",
19551956
"serde_json",
1957+
"thiserror 2.0.11",
19561958
]
19571959

19581960
[[package]]
@@ -2645,6 +2647,51 @@ dependencies = [
26452647
"libc",
26462648
]
26472649

2650+
[[package]]
2651+
name = "pest"
2652+
version = "2.7.15"
2653+
source = "registry+https://github.com/rust-lang/crates.io-index"
2654+
checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc"
2655+
dependencies = [
2656+
"memchr",
2657+
"thiserror 2.0.11",
2658+
"ucd-trie",
2659+
]
2660+
2661+
[[package]]
2662+
name = "pest_derive"
2663+
version = "2.7.15"
2664+
source = "registry+https://github.com/rust-lang/crates.io-index"
2665+
checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e"
2666+
dependencies = [
2667+
"pest",
2668+
"pest_generator",
2669+
]
2670+
2671+
[[package]]
2672+
name = "pest_generator"
2673+
version = "2.7.15"
2674+
source = "registry+https://github.com/rust-lang/crates.io-index"
2675+
checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b"
2676+
dependencies = [
2677+
"pest",
2678+
"pest_meta",
2679+
"proc-macro2",
2680+
"quote",
2681+
"syn 2.0.96",
2682+
]
2683+
2684+
[[package]]
2685+
name = "pest_meta"
2686+
version = "2.7.15"
2687+
source = "registry+https://github.com/rust-lang/crates.io-index"
2688+
checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea"
2689+
dependencies = [
2690+
"once_cell",
2691+
"pest",
2692+
"sha2",
2693+
]
2694+
26482695
[[package]]
26492696
name = "phf"
26502697
version = "0.11.3"
@@ -4780,7 +4827,6 @@ version = "1.0.135"
47804827
source = "registry+https://github.com/rust-lang/crates.io-index"
47814828
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
47824829
dependencies = [
4783-
"indexmap",
47844830
"itoa",
47854831
"memchr",
47864832
"ryu",
@@ -5486,6 +5532,12 @@ dependencies = [
54865532
"regex-lite",
54875533
]
54885534

5535+
[[package]]
5536+
name = "ucd-trie"
5537+
version = "0.1.7"
5538+
source = "registry+https://github.com/rust-lang/crates.io-index"
5539+
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
5540+
54895541
[[package]]
54905542
name = "ui_test"
54915543
version = "0.28.0"

src/bootstrap/src/utils/proc_macro_deps.rs

+15
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,43 @@ pub static CRATES: &[&str] = &[
66
"annotate-snippets",
77
"anstyle",
88
"basic-toml",
9+
"block-buffer",
910
"bumpalo",
11+
"cfg-if",
12+
"cpufeatures",
13+
"crypto-common",
1014
"darling",
1115
"darling_core",
1216
"derive_builder_core",
17+
"digest",
1318
"fluent-bundle",
1419
"fluent-langneg",
1520
"fluent-syntax",
1621
"fnv",
22+
"generic-array",
1723
"heck",
1824
"ident_case",
1925
"intl-memoizer",
2026
"intl_pluralrules",
27+
"libc",
2128
"log",
2229
"memchr",
2330
"mime",
2431
"mime_guess",
2532
"minimal-lexical",
2633
"nom",
2734
"num-conv",
35+
"once_cell",
36+
"pest",
37+
"pest_generator",
38+
"pest_meta",
2839
"proc-macro2",
2940
"quote",
3041
"rinja_parser",
3142
"rustc-hash",
3243
"self_cell",
3344
"serde",
45+
"sha2",
3446
"smallvec",
3547
"stable_deref_trait",
3648
"strsim",
@@ -40,12 +52,15 @@ pub static CRATES: &[&str] = &[
4052
"time-core",
4153
"tinystr",
4254
"type-map",
55+
"typenum",
56+
"ucd-trie",
4357
"unic-langid",
4458
"unic-langid-impl",
4559
"unic-langid-macros",
4660
"unicase",
4761
"unicode-ident",
4862
"unicode-width",
63+
"version_check",
4964
"wasm-bindgen-backend",
5065
"wasm-bindgen-macro-support",
5166
"wasm-bindgen-shared",

src/tools/jsondocck/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
jsonpath_lib = "0.3"
7+
jsonpath-rust = "1.0.0"
88
getopts = "0.2"
99
regex = "1.4"
1010
shlex = "1.0"

src/tools/jsondocck/src/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ impl Cache {
3030

3131
// FIXME: Make this failible, so jsonpath syntax error has line number.
3232
pub fn select(&self, path: &str) -> Vec<&Value> {
33-
jsonpath_lib::select(&self.value, path).unwrap()
33+
jsonpath_rust::query::js_path_vals(path, &self.value).unwrap()
3434
}
3535
}

tests/rustdoc-json/assoc_items.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
pub struct Simple;
44

55
impl Simple {
6-
//@ has "$.index[*][?(@.name=='CONSTANT')].inner.assoc_const"
6+
//@ has "$.index[?(@.name=='CONSTANT')].inner.assoc_const"
77
pub const CONSTANT: usize = 0;
88
}
99

1010
pub trait EasyToImpl {
11-
//@ has "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type"
12-
//@ is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.type" null
13-
//@ is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.bounds" []
11+
//@ has "$.index[?(@.docs=='ToDeclare trait')].inner.assoc_type"
12+
//@ is "$.index[?(@.docs=='ToDeclare trait')].inner.assoc_type.type" null
13+
//@ is "$.index[?(@.docs=='ToDeclare trait')].inner.assoc_type.bounds" []
1414
/// ToDeclare trait
1515
type ToDeclare;
16-
//@ has "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const"
17-
//@ is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.value" null
18-
//@ is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.type.primitive" '"usize"'
16+
//@ has "$.index[?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const"
17+
//@ is "$.index[?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.value" null
18+
//@ is "$.index[?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.type.primitive" '"usize"'
1919
/// AN_ATTRIBUTE trait
2020
const AN_ATTRIBUTE: usize;
2121
}
2222

2323
impl EasyToImpl for Simple {
24-
//@ has "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type"
25-
//@ is "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type.type.primitive" \"usize\"
24+
//@ has "$.index[?(@.docs=='ToDeclare impl')].inner.assoc_type"
25+
//@ is "$.index[?(@.docs=='ToDeclare impl')].inner.assoc_type.type.primitive" \"usize\"
2626
/// ToDeclare impl
2727
type ToDeclare = usize;
2828

29-
//@ has "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const"
30-
//@ is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.type.primitive" \"usize\"
31-
//@ is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.value" \"12\"
29+
//@ has "$.index[?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const"
30+
//@ is "$.index[?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.type.primitive" \"usize\"
31+
//@ is "$.index[?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.value" \"12\"
3232
/// AN_ATTRIBUTE impl
3333
const AN_ATTRIBUTE: usize = 12;
3434
}

tests/rustdoc-json/assoc_type.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/98547>.
22

3-
//@ has "$.index[*][?(@.name=='Trait')]"
4-
//@ has "$.index[*][?(@.name=='AssocType')]"
5-
//@ has "$.index[*][?(@.name=='S')]"
6-
//@ has "$.index[*][?(@.name=='S2')]"
3+
//@ has "$.index[?(@.name=='Trait')]"
4+
//@ has "$.index[?(@.name=='AssocType')]"
5+
//@ has "$.index[?(@.name=='S')]"
6+
//@ has "$.index[?(@.name=='S2')]"
77

88
pub trait Trait {
99
type AssocType;
+16-16
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
//@ is "$.index[*][?(@.name=='not')].attrs" []
2-
//@ is "$.index[*][?(@.name=='not')].deprecation" null
1+
//@ is "$.index[?(@.name=='not')].attrs" []
2+
//@ is "$.index[?(@.name=='not')].deprecation" null
33
pub fn not() {}
44

5-
//@ is "$.index[*][?(@.name=='raw')].attrs" []
6-
//@ is "$.index[*][?(@.name=='raw')].deprecation" '{"since": null, "note": null}'
5+
//@ is "$.index[?(@.name=='raw')].attrs" []
6+
//@ is "$.index[?(@.name=='raw')].deprecation" '{"since": null, "note": null}'
77
#[deprecated]
88
pub fn raw() {}
99

10-
//@ is "$.index[*][?(@.name=='equals_string')].attrs" []
11-
//@ is "$.index[*][?(@.name=='equals_string')].deprecation" '{"since": null, "note": "here is a reason"}'
10+
//@ is "$.index[?(@.name=='equals_string')].attrs" []
11+
//@ is "$.index[?(@.name=='equals_string')].deprecation" '{"since": null, "note": "here is a reason"}'
1212
#[deprecated = "here is a reason"]
1313
pub fn equals_string() {}
1414

15-
//@ is "$.index[*][?(@.name=='since')].attrs" []
16-
//@ is "$.index[*][?(@.name=='since')].deprecation" '{"since": "yoinks ago", "note": null}'
15+
//@ is "$.index[?(@.name=='since')].attrs" []
16+
//@ is "$.index[?(@.name=='since')].deprecation" '{"since": "yoinks ago", "note": null}'
1717
#[deprecated(since = "yoinks ago")]
1818
pub fn since() {}
1919

20-
//@ is "$.index[*][?(@.name=='note')].attrs" []
21-
//@ is "$.index[*][?(@.name=='note')].deprecation" '{"since": null, "note": "7"}'
20+
//@ is "$.index[?(@.name=='note')].attrs" []
21+
//@ is "$.index[?(@.name=='note')].deprecation" '{"since": null, "note": "7"}'
2222
#[deprecated(note = "7")]
2323
pub fn note() {}
2424

25-
//@ is "$.index[*][?(@.name=='since_and_note')].attrs" []
26-
//@ is "$.index[*][?(@.name=='since_and_note')].deprecation" '{"since": "tomorrow", "note": "sorry"}'
25+
//@ is "$.index[?(@.name=='since_and_note')].attrs" []
26+
//@ is "$.index[?(@.name=='since_and_note')].deprecation" '{"since": "tomorrow", "note": "sorry"}'
2727
#[deprecated(since = "tomorrow", note = "sorry")]
2828
pub fn since_and_note() {}
2929

30-
//@ is "$.index[*][?(@.name=='note_and_since')].attrs" []
31-
//@ is "$.index[*][?(@.name=='note_and_since')].deprecation" '{"since": "a year from tomorrow", "note": "your welcome"}'
30+
//@ is "$.index[?(@.name=='note_and_since')].attrs" []
31+
//@ is "$.index[?(@.name=='note_and_since')].deprecation" '{"since": "a year from tomorrow", "note": "your welcome"}'
3232
#[deprecated(note = "your welcome", since = "a year from tomorrow")]
3333
pub fn note_and_since() {}
3434

35-
//@ is "$.index[*][?(@.name=='neither_but_parens')].attrs" []
36-
//@ is "$.index[*][?(@.name=='neither_but_parens')].deprecation" '{"since": null, "note": null}'
35+
//@ is "$.index[?(@.name=='neither_but_parens')].attrs" []
36+
//@ is "$.index[?(@.name=='neither_but_parens')].deprecation" '{"since": null, "note": null}'
3737
#[deprecated()]
3838
pub fn neither_but_parens() {}
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+
//@ 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\"]"]'
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]"]'
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\"]"]'
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]"]'
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]"]'
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]"]'
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]"]'
10+
//@ is "$.index[?(@.name=='Variant')].attrs" '["#[non_exhaustive]"]'
1111
#[non_exhaustive]
1212
Variant(i64),
1313
}
1414

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

tests/rustdoc-json/attrs/repr_align.rs

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

3-
//@ is "$.index[*][?(@.name=='Aligned')].attrs" '["#[attr = Repr([ReprAlign(Align(4 bytes))])]\n"]'
3+
//@ is "$.index[?(@.name=='Aligned')].attrs" '["#[attr = Repr([ReprAlign(Align(4 bytes))])]\n"]'
44
#[repr(align(4))]
55
pub struct Aligned {
66
a: i8,

tests/rustdoc-json/attrs/repr_c.rs

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

3-
//@ is "$.index[*][?(@.name=='ReprCStruct')].attrs" '["#[attr = Repr([ReprC])]\n"]'
3+
//@ is "$.index[?(@.name=='ReprCStruct')].attrs" '["#[attr = Repr([ReprC])]\n"]'
44
#[repr(C)]
55
pub struct ReprCStruct(pub i64);
66

7-
//@ is "$.index[*][?(@.name=='ReprCEnum')].attrs" '["#[attr = Repr([ReprC])]\n"]'
7+
//@ is "$.index[?(@.name=='ReprCEnum')].attrs" '["#[attr = Repr([ReprC])]\n"]'
88
#[repr(C)]
99
pub enum ReprCEnum {
1010
First,
1111
}
1212

13-
//@ is "$.index[*][?(@.name=='ReprCUnion')].attrs" '["#[attr = Repr([ReprC])]\n"]'
13+
//@ is "$.index[?(@.name=='ReprCUnion')].attrs" '["#[attr = Repr([ReprC])]\n"]'
1414
#[repr(C)]
1515
pub union ReprCUnion {
1616
pub left: i64,

0 commit comments

Comments
 (0)