Skip to content

Commit fcfb089

Browse files
committed
tests for label_traits
1 parent 4843bad commit fcfb089

5 files changed

Lines changed: 64 additions & 8 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(doc_label_trait)]
2+
#![crate_name = "foo"]
3+
4+
#[doc(label_trait)]
5+
pub trait Labeled {}
6+
7+
#[doc(label_trait)]
8+
pub trait AlsoLabeled {}
9+
10+
pub trait Plain {}
11+
12+
//@ has 'foo/struct.Tagged.html'
13+
//@ has - '//a[@class="impl-label-trait-full-badge"][@href="trait.Labeled.html"][@title="foo::Labeled"]' 'Labeled'
14+
// Badges are sorted by trait name, so `AlsoLabeled` precedes `Labeled`.
15+
//@ has - '//div[@class="impl-label-trait-full-badge-container"]/a[1]' 'AlsoLabeled'
16+
//@ has - '//div[@class="impl-label-trait-full-badge-container"]/a[2]' 'Labeled'
17+
pub struct Tagged;
18+
impl Labeled for Tagged {}
19+
impl AlsoLabeled for Tagged {}
20+
impl Plain for Tagged {}
21+
22+
//@ has 'foo/struct.Untagged.html'
23+
//@ count - '//div[@class="impl-label-trait-full-badge-container"]' 0
24+
pub struct Untagged;
25+
impl Plain for Untagged {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(doc_label_trait)]
2+
#![crate_name = "foo"]
3+
4+
#[doc(label_trait)]
5+
pub trait Labeled {}
6+
7+
pub trait Bound {}
8+
9+
// A conditional impl: the badge is rendered unconditionally even though the
10+
// impl only holds for `T: Bound`.
11+
//@ has 'foo/struct.Wrapper.html' '//a[@class="impl-label-trait-full-badge"]' 'Labeled'
12+
pub struct Wrapper<T>(pub T);
13+
impl<T: Bound> Labeled for Wrapper<T> {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(doc_label_trait, negative_impls)]
2+
#![crate_name = "foo"]
3+
4+
#[doc(label_trait)]
5+
pub trait Labeled {}
6+
7+
// A negative impl must not produce a badge.
8+
//@ count 'foo/struct.Neg.html' '//div[@class="impl-label-trait-full-badge-container"]' 0
9+
pub struct Neg;
10+
impl !Labeled for Neg {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(doc_label_trait)]
2+
#![crate_name = "foo"]
3+
4+
#[doc(label_trait)]
5+
pub trait Base {}
6+
7+
pub trait Derived: Base {}
8+
9+
//@ has 'foo/struct.S.html'
10+
// Implementing `Derived` requires implementing the label supertrait `Base`,
11+
// so its badge shows up.
12+
//@ count - '//a[@class="impl-label-trait-full-badge"]' 1
13+
//@ has - '//a[@class="impl-label-trait-full-badge"]' 'Base'
14+
pub struct S;
15+
impl Base for S {}
16+
impl Derived for S {}

tests/rustdoc-html/notable-trait/doc-label_trait.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)