Skip to content

Commit c3fcfa8

Browse files
committed
Rustdoc-Json: Add tests for trait impls.
1 parent 2e44c17 commit c3fcfa8

7 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct ForeignStruct;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub trait ForeignTrait {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// aux-build: foreign_trait.rs
2+
extern crate foreign_trait;
3+
4+
/// ForeignTrait id hack
5+
pub use foreign_trait::ForeignTrait as _;
6+
// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.id"
7+
8+
pub struct LocalStruct;
9+
// @set LocalStruct = "$.index[*][?(@.name=='LocalStruct')].id"
10+
11+
/// foreign for local
12+
impl foreign_trait::ForeignTrait for LocalStruct {}
13+
14+
// @set impl = "$.index[*][?(@.docs=='foreign for local')].id"
15+
// @is "$.index[*][?(@.docs=='foreign for local')].inner.for.inner.id" $LocalStruct
16+
// @is "$.index[*][?(@.docs=='foreign for local')].inner.trait.id" $ForeignTrait
17+
18+
// @has "$.index[*][?(@.name=='LocalStruct')].inner.impls[*]" $impl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// aux-build: foreign_struct.rs
2+
extern crate foreign_struct;
3+
4+
/// ForeignStruct id hack
5+
pub use foreign_struct::ForeignStruct as _;
6+
// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.id"
7+
8+
pub trait LocalTrait {}
9+
// @set LocalTrait = "$.index[*][?(@.name=='LocalTrait')].id"
10+
11+
/// local for foreign
12+
impl LocalTrait for foreign_struct::ForeignStruct {}
13+
14+
// @set impl = "$.index[*][?(@.docs=='local for foreign')].id"
15+
// @is "$.index[*][?(@.docs=='local for foreign')].inner.trait.id" $LocalTrait
16+
// @is "$.index[*][?(@.docs=='local for foreign')].inner.for.inner.id" $ForeignStruct
17+
18+
// @is "$.index[*][?(@.name=='LocalTrait')].inner.implementations[*]" $impl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(no_core)]
2+
#![no_core]
3+
4+
// @set struct = "$.index[*][?(@.name=='Struct')].id"
5+
pub struct Struct;
6+
// @set trait = "$.index[*][?(@.name=='Trait')].id"
7+
pub trait Trait {}
8+
// @set impl = "$.index[*][?(@.docs=='impl')].id"
9+
/// impl
10+
impl Trait for Struct {}
11+
12+
// @is "$.index[*][?(@.name=='Struct')].inner.impls[*]" $impl
13+
// @is "$.index[*][?(@.name=='Trait')].inner.implementations[*]" $impl
14+
// @is "$.index[*][?(@.docs=='impl')].inner.trait.id" $trait
15+
// @is "$.index[*][?(@.docs=='impl')].inner.for.inner.id" $struct
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(no_core)]
2+
#![feature(rustdoc_internals)]
3+
#![no_core]
4+
5+
// @set Local = "$.index[*][?(@.name=='Local')].id"
6+
pub trait Local {}
7+
8+
// @is "$.index[*][?(@.docs=='Local for bool')].inner.trait.id" $Local
9+
// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.kind" '"primitive"'
10+
// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.inner" '"bool"'
11+
/// Local for bool
12+
impl Local for bool {}
13+
14+
// @set impl = "$.index[*][?(@.docs=='Local for bool')].id"
15+
// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl
16+
17+
// FIXME(#101695): Test bool's `impls` include "Local for bool"
18+
// @has "$.index[*][?(@.name=='bool')]"
19+
#[doc(primitive = "bool")]
20+
/// Boolean docs
21+
mod prim_bool {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @set local = "$.index[*][?(@.name=='Local')]"
2+
pub trait Local {}
3+
4+
// @set impl = "$.index[*][?(@.docs=='local for bool')].id"
5+
// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl
6+
/// local for bool
7+
impl Local for bool {}

0 commit comments

Comments
 (0)