3a3f70c94e
This class originated in the very first commit of `rustdoc_ng`, and was used
to add a color border around the item decl based on its kind.
4fd061c426/src/rustdoc_ng/html/static/main.css (L102-L106)
The item decl no longer has a border, and there aren't any
kind-specific styles in modern rustdoc's rendering of this UI item.
Most of this commit is updating test cases so that they use `item-decl` to
find the `<pre>` tag instead of relying on the fact that the class name
had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
83 lines
2.5 KiB
Rust
83 lines
2.5 KiB
Rust
// ignore-tidy-linelength
|
|
// aux-build:normalize-assoc-item.rs
|
|
// build-aux-docs
|
|
// compile-flags:-Znormalize-docs
|
|
|
|
pub trait Trait {
|
|
type X;
|
|
}
|
|
|
|
impl Trait for usize {
|
|
type X = isize;
|
|
}
|
|
|
|
impl Trait for () {
|
|
type X = fn() -> i32;
|
|
}
|
|
|
|
impl Trait for isize {
|
|
type X = <() as Trait>::X;
|
|
}
|
|
|
|
// @has 'normalize_assoc_item/fn.f.html' '//div[@class="item-decl"]/pre[@class="rust"]' 'pub fn f() -> isize'
|
|
pub fn f() -> <usize as Trait>::X {
|
|
0
|
|
}
|
|
|
|
// @has 'normalize_assoc_item/fn.f2.html' '//div[@class="item-decl"]/pre[@class="rust"]' 'pub fn f2() -> fn() -> i32'
|
|
pub fn f2() -> <isize as Trait>::X {
|
|
todo!()
|
|
}
|
|
|
|
pub struct S {
|
|
// @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S, Global>'
|
|
pub box_me_up: <S as Trait>::X,
|
|
// @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)'
|
|
pub generic: <Generic<usize> as Trait>::X,
|
|
}
|
|
|
|
impl Trait for S {
|
|
type X = Box<S>;
|
|
}
|
|
|
|
pub struct Generic<Inner>(Inner);
|
|
|
|
impl<Inner: Trait> Trait for Generic<Inner> {
|
|
type X = (Inner, Inner::X);
|
|
}
|
|
|
|
// These can't be normalized because they depend on a generic parameter.
|
|
// However the user can choose whether the text should be displayed as `Inner::X` or `<Inner as Trait>::X`.
|
|
|
|
// @has 'normalize_assoc_item/struct.Unknown.html' '//div[@class="item-decl"]/pre[@class="rust"]' 'pub struct Unknown<Inner: Trait>(pub <Inner as Trait>::X);'
|
|
pub struct Unknown<Inner: Trait>(pub <Inner as Trait>::X);
|
|
|
|
// @has 'normalize_assoc_item/struct.Unknown2.html' '//div[@class="item-decl"]/pre[@class="rust"]' 'pub struct Unknown2<Inner: Trait>(pub Inner::X);'
|
|
pub struct Unknown2<Inner: Trait>(pub Inner::X);
|
|
|
|
trait Lifetimes<'a> {
|
|
type Y;
|
|
}
|
|
|
|
impl<'a> Lifetimes<'a> for usize {
|
|
type Y = &'a isize;
|
|
}
|
|
|
|
// @has 'normalize_assoc_item/fn.g.html' '//div[@class="item-decl"]/pre[@class="rust"]' "pub fn g() -> &isize"
|
|
pub fn g() -> <usize as Lifetimes<'static>>::Y {
|
|
&0
|
|
}
|
|
|
|
// @has 'normalize_assoc_item/constant.A.html' '//div[@class="item-decl"]/pre[@class="rust"]' "pub const A: &isize"
|
|
pub const A: <usize as Lifetimes<'static>>::Y = &0;
|
|
|
|
// test cross-crate re-exports
|
|
extern crate inner;
|
|
// @has 'normalize_assoc_item/fn.foo.html' '//div[@class="item-decl"]/pre[@class="rust"]' "pub fn foo() -> i32"
|
|
pub use inner::foo;
|
|
|
|
// @has 'normalize_assoc_item/fn.h.html' '//div[@class="item-decl"]/pre[@class="rust"]' "pub fn h<T>() -> IntoIter<T, Global>"
|
|
pub fn h<T>() -> <Vec<T> as IntoIterator>::IntoIter {
|
|
vec![].into_iter()
|
|
}
|