Skip to content

Commit

Permalink
rustdoc-json: Add tests for visibility of impls
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed May 15, 2023
1 parent 3603a84 commit 99cae9c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/rustdoc-json/impls/impl_item_visibility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![feature(no_core)]
#![no_core]

pub struct Foo;

/// impl Foo priv
impl Foo {
fn baz() {}
}
// @!has '$.index[*][?(@.docs=="impl Foo priv")]'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
28 changes: 28 additions & 0 deletions tests/rustdoc-json/impls/impl_item_visibility_show_hidden.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// compile-flags: --document-hidden-items
#![feature(no_core)]
#![no_core]

pub struct Foo;

/// impl Foo priv
impl Foo {
fn baz() {}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'
27 changes: 27 additions & 0 deletions tests/rustdoc-json/impls/impl_item_visibility_show_private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// compile-flags: --document-private-items
#![feature(no_core)]
#![no_core]

pub struct Foo;

/// impl Foo priv
impl Foo {
fn baz() {}
}
// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"'


/// impl Foo pub
impl Foo {
pub fn qux() {}
}
// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"'


/// impl Foo hidden
impl Foo {
#[doc(hidden)]
pub fn __quazl(){}
}
// FIXME(#111564): Is this the right behaviour?
// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"'

0 comments on commit 99cae9c

Please sign in to comment.