Skip to content

Commit 434b69a

Browse files
committedNov 7, 2023
tests/rustdoc-json: Rewrite tests no not use #![no_core].
1 parent 0875f45 commit 434b69a

5 files changed

+31
-37
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// https://github.com/rust-lang/rust/issues/100252
22

3-
#![feature(no_core)]
4-
#![no_core]
5-
63
mod bar {
7-
// @set baz = "$.index[*][?(@.inner.struct)].id"
4+
// @set baz = "$.index[*][?(@.name == 'Baz')].id"
85
pub struct Baz;
9-
// @set impl = "$.index[*][?(@.inner.impl)].id"
6+
// @set impl = "$.index[*][?(@.docs == 'impl')].id"
7+
/// impl
108
impl Baz {
11-
// @set doit = "$.index[*][?(@.inner.function)].id"
9+
// @set doit = "$.index[*][?(@.name == 'doit')].id"
1210
pub fn doit() {}
1311
}
1412
}
@@ -18,5 +16,5 @@ pub use bar::Baz;
1816

1917
// @is "$.index[*].inner.module.items[*]" $import
2018
// @is "$.index[*].inner.import.id" $baz
21-
// @is "$.index[*].inner.struct.impls[*]" $impl
22-
// @is "$.index[*].inner.impl.items[*]" $doit
19+
// @has "$.index[*][?(@.name == 'Baz')].inner.struct.impls[*]" $impl
20+
// @is "$.index[*][?(@.docs=='impl')].inner.impl.items[*]" $doit
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
4-
// @count "$.index[*][?(@.inner.impl)]" 1
1+
// @has "$.index[*][?(@.docs=='Here')]"
2+
// @!has "$.index[*][?(@.docs=='Not Here')]"
53
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
64
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
75
// @has "$.index[*][?(@.name=='PubTrait')]"
@@ -11,5 +9,7 @@ pub trait PubTrait {}
119
pub struct HiddenPubStruct;
1210
pub struct NotHiddenPubStruct;
1311

12+
/// Not Here
1413
impl PubTrait for HiddenPubStruct {}
14+
/// Here
1515
impl PubTrait for NotHiddenPubStruct {}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
4-
// @count "$.index[*][?(@.inner.impl)]" 1
5-
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
6-
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
71
// @has "$.index[*][?(@.name=='PubTrait')]"
82
pub trait PubTrait {}
93

104
#[doc(hidden)]
115
pub mod hidden {
6+
// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
127
pub struct HiddenPubStruct;
138

9+
// @!has "$.index[*][?(@.docs == 'Not Here')]"
10+
/// Not Here
1411
impl crate::PubTrait for HiddenPubStruct {}
1512
}
1613

1714
pub mod not_hidden {
15+
// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
1816
pub struct NotHiddenPubStruct;
1917

18+
// @has "$.index[*][?(@.docs == 'Here')]"
19+
/// Here
2020
impl crate::PubTrait for NotHiddenPubStruct {}
2121
}
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
41
// @set struct = "$.index[*][?(@.name=='Struct')].id"
52
pub struct Struct;
63
// @set trait = "$.index[*][?(@.name=='Trait')].id"
@@ -9,7 +6,7 @@ pub trait Trait {}
96
/// impl
107
impl Trait for Struct {}
118

12-
// @is "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
9+
// @has "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl
1310
// @is "$.index[*][?(@.name=='Trait')].inner.trait.implementations[*]" $impl
1411
// @is "$.index[*][?(@.docs=='impl')].inner.impl.trait.id" $trait
1512
// @is "$.index[*][?(@.docs=='impl')].inner.impl.for.resolved_path.id" $struct
+14-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
#![feature(no_core)]
2-
#![no_core]
3-
4-
// @set wham = "$.index[*][?(@.name=='Wham')].id"
5-
// @count "$.index[*][?(@.name=='Wham')].inner.trait.implementations[*]" 1
6-
// @set gmWham = "$.index[*][?(@.name=='Wham')].inner.trait.implementations[0]"
71
pub trait Wham {}
8-
9-
// @count "$.index[*][?(@.name=='GeorgeMichael')].inner.struct.impls[*]" 1
10-
// @is "$.index[*][?(@.name=='GeorgeMichael')].inner.struct.impls[0]" $gmWham
11-
// @set gm = "$.index[*][?(@.name=='Wham')].id"
12-
13-
// jsonpath_lib isnt expressive enough (for now) to get the "impl" item, so we
14-
// just check it isn't pointing to the type, but when you port to jsondocck-ng
15-
// check what the impl item is
16-
// @!is "$.index[*][?(@.name=='Wham')].inner.trait.implementations[0]" $gm
172
pub struct GeorgeMichael {}
183

4+
/// Wham for George Michael
195
impl Wham for GeorgeMichael {}
6+
7+
// Find IDs.
8+
// @set wham = "$.index[*][?(@.name=='Wham')].id"
9+
// @set gmWham = "$.index[*][?(@.docs=='Wham for George Michael')].id"
10+
// @set gm = "$.index[*][?(@.name=='GeorgeMichael')].id"
11+
12+
// Both struct and trait point to impl.
13+
// @has "$.index[*][?(@.name=='GeorgeMichael')].inner.struct.impls[*]" $gmWham
14+
// @is "$.index[*][?(@.name=='Wham')].inner.trait.implementations[*]" $gmWham
15+
16+
// Impl points to both struct and trait.
17+
// @is "$.index[*][?(@.docs == 'Wham for George Michael')].inner.impl.trait.id" $wham
18+
// @is "$.index[*][?(@.docs == 'Wham for George Michael')].inner.impl.for.resolved_path.id" $gm

0 commit comments

Comments
 (0)
Please sign in to comment.