Skip to content

Commit

Permalink
Add trait implementors sidebar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Nov 27, 2021
1 parent fe6b0b8 commit 3ff81db
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
49 changes: 49 additions & 0 deletions src/test/rustdoc/sidebar-links-impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// issue #56018: "Implementations on Foreign Types" sidebar items should link to specific impls

#![crate_name = "foo"]

// @has foo/trait.Foo.html
// @has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]' 'Implementations on Foreign Types'
// @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types'
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-u32"]' 'u32'
// @has - '//div[@id="impl-Foo-for-u32"]//h3[@class="code-header in-band"]' 'impl Foo for u32'
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str"
// @has - '//div[@id="impl-Foo-for-%26%27a%20str"]//h3[@class="code-header in-band"]' "impl<'a> Foo for &'a str"
pub trait Foo {}

impl Foo for u32 {}

impl<'a> Foo for &'a str {}

// Issue #91118" "Implementors column on trait page is always empty"

pub struct B;
pub struct A;
struct C;

// @has foo/trait.Bar.html
// @has - '//*[@class="sidebar-title"]/a[@href="#implementors"]' 'Implementors'
// @has - '//h2[@id="implementors"]' 'Implementors'
// @!has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]'
// @!has - '//h2[@id="foreign-impls"]'

// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Bar"]' '&A'
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Bar-1"]' 'A'
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Bar-2"]' 'B'

// @has - '//div[@id="impl-Bar"]//h3[@class="code-header in-band"]' 'impl Bar for &A'
// @has - '//div[@id="impl-Bar-1"]//h3[@class="code-header in-band"]' 'impl Bar for A'
// @has - '//div[@id="impl-Bar-2"]//h3[@class="code-header in-band"]' 'impl Bar for B'
pub trait Bar {}
impl Bar for B {}
impl Bar for A {}
impl Bar for &A {}
impl Bar for C {}

// @has foo/trait.NotImpled.html
// @!has - '//*[@class="sidebar-title"]/a[@href="#implementors"]'
// FIXME: Is this the semantics we want
// @has - '//h2[@id="implementors"]' 'Implementors'
// @!has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]'
// @!has - '//h2[@id="foreign-impls"]'
pub trait NotImpled {}
16 changes: 0 additions & 16 deletions src/test/rustdoc/sidebar-links-to-foreign-impl.rs

This file was deleted.

0 comments on commit 3ff81db

Please sign in to comment.