Rollup merge of #85970 - jsha:remove-methods-implementors, r=GuillaumeGomez

Remove methods under Implementors on trait pages

As discussed at https://github.com/rust-lang/rust/issues/84326#issuecomment-842652412.

On a trait page, the "Implementors" section currently lists all methods of each implementor. That duplicates the method definitions on the trait itself, and is usually not very useful. So the implementors are collapsed by default. This PR changes rustdoc to just not render them at all. Any documentation specific to an implementor can be found by clicking through to the implementor's page.

This moves the "portability" info inside the `<summary>` tags so it is still visible on trait pages (as originally implemented in #79201). That also means it will be visible on struct/enum pages when methods are collapsed.

Add `#[doc(hidden)]` to all implementations of `Iterator::__iterator_get_unchecked` that didn't already have it. Otherwise, due to #86145, the structs/enums with those implementations would generate documentation for them, and that documentation would have a broken link into the Iterator page. Those links were already "broken" but not detected by the link-checker, because they pointed to one of the Implementors on the Iterator page, which happened to have the right anchor name.

This reduces the Read trait's page size from 128kB to 68kB (uncompressed) and from 12,125 bytes to 9,989 bytes (gzipped
Demo:

https://hoffman-andrews.com/rust/remove-methods-implementors/std/string/struct.String.html#trait-implementations
https://hoffman-andrews.com/rust/remove-methods-implementors/std/io/trait.Read.html#implementors

r? `@GuillaumeGomez`
This commit is contained in:
Yuki Okushi 2021-06-17 21:56:42 +09:00 committed by GitHub
commit 9521da7179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 114 additions and 153 deletions

View file

@ -38,6 +38,7 @@ impl<T> Iterator for IntoIter<T> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -103,6 +103,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -89,6 +89,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -163,6 +163,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
self.len()
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -132,6 +132,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -58,6 +58,7 @@ where
self.it.map(T::clone).fold(init, f)
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
where
Self: TrustedRandomAccess,

View file

@ -74,6 +74,7 @@ where
self.it.count()
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
where
Self: TrustedRandomAccess,

View file

@ -111,6 +111,7 @@ where
}
#[rustc_inherit_overflow_checks]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <Self as Iterator>::Item
where
Self: TrustedRandomAccess,

View file

@ -114,6 +114,7 @@ where
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -122,6 +122,7 @@ where
self.iter.fold(init, map_fold(self.f, g))
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> B
where
Self: TrustedRandomAccess,

View file

@ -88,6 +88,7 @@ where
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -667,6 +667,7 @@ impl<A: Step> Iterator for ops::Range<A> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,

View file

@ -2148,6 +2148,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> {
self.iter.last()
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a [T; N] {
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are
// transferred to the caller.
@ -2260,6 +2261,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunksMut<'a, T, N> {
self.iter.last()
}
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a mut [T; N] {
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are transferred to
// the caller.

View file

@ -295,6 +295,7 @@ impl Iterator for Bytes<'_> {
}
#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> u8 {
// SAFETY: the caller must uphold the safety contract
// for `Iterator::__iterator_get_unchecked`.

View file

@ -490,7 +490,6 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", false)
.into(),
("auto-collapse-implementors", "Auto-hide implementors of a trait", true).into(),
("go-to-only-result", "Directly go to item in search if there is only one result", false)
.into(),
("line-numbers", "Show line numbers on code examples", false).into(),
@ -724,6 +723,8 @@ fn short_item_info(
extra_info
}
// Render the list of items inside one of the sections "Trait Implementations",
// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
fn render_impls(
cx: &Context<'_>,
w: &mut Buffer,
@ -746,8 +747,6 @@ fn render_impls(
containing_item,
assoc_link,
RenderMode::Normal,
containing_item.stable_since(tcx).as_deref(),
containing_item.const_stable_since(tcx).as_deref(),
true,
None,
false,
@ -1025,7 +1024,6 @@ fn render_assoc_items(
Some(v) => v,
None => return,
};
let tcx = cx.tcx();
let cache = cx.cache();
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
if !non_trait.is_empty() {
@ -1059,8 +1057,6 @@ fn render_assoc_items(
containing_item,
AssocItemLink::Anchor(None),
render_mode,
containing_item.stable_since(tcx).as_deref(),
containing_item.const_stable_since(tcx).as_deref(),
true,
None,
false,
@ -1261,8 +1257,6 @@ fn render_impl(
parent: &clean::Item,
link: AssocItemLink<'_>,
render_mode: RenderMode,
outer_version: Option<&str>,
outer_const_version: Option<&str>,
show_def_docs: bool,
use_absolute: Option<bool>,
is_on_foreign_type: bool,
@ -1279,23 +1273,23 @@ fn render_impl(
// For trait implementations, the `interesting` output contains all methods that have doc
// comments, and the `boring` output contains all methods that do not. The distinction is
// used to allow hiding the boring methods.
// `containing_item` is used for rendering stability info. If the parent is a trait impl,
// `containing_item` will the grandparent, since trait impls can't have stability attached.
fn doc_impl_item(
boring: &mut Buffer,
interesting: &mut Buffer,
cx: &Context<'_>,
item: &clean::Item,
parent: &clean::Item,
containing_item: &clean::Item,
link: AssocItemLink<'_>,
render_mode: RenderMode,
is_default_item: bool,
outer_version: Option<&str>,
outer_const_version: Option<&str>,
trait_: Option<&clean::Trait>,
show_def_docs: bool,
) {
let item_type = item.type_();
let name = item.name.as_ref().unwrap();
let tcx = cx.tcx();
let render_method_item = match render_mode {
RenderMode::Normal => true,
@ -1364,6 +1358,8 @@ fn render_impl(
"<div id=\"{}\" class=\"{}{} has-srclink\">",
id, item_type, in_trait_class,
);
render_rightside(w, cx, item, containing_item);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("<code>");
render_assoc_item(
w,
@ -1373,15 +1369,6 @@ fn render_impl(
cx,
);
w.write_str("</code>");
render_stability_since_raw(
w,
item.stable_since(tcx).as_deref(),
item.const_stable_since(tcx).as_deref(),
outer_version,
outer_const_version,
);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write_srclink(cx, item, w);
w.write_str("</div>");
}
}
@ -1390,9 +1377,11 @@ fn render_impl(
let id = cx.derive_id(source_id.clone());
write!(
w,
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
"<div id=\"{}\" class=\"{}{} has-srclink\">",
id, item_type, in_trait_class
);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("<code>");
assoc_type(
w,
item,
@ -1403,7 +1392,6 @@ fn render_impl(
cx,
);
w.write_str("</code>");
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("</div>");
}
clean::AssocConstItem(ref ty, ref default) => {
@ -1411,9 +1399,12 @@ fn render_impl(
let id = cx.derive_id(source_id.clone());
write!(
w,
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
"<div id=\"{}\" class=\"{}{} has-srclink\">",
id, item_type, in_trait_class
);
render_rightside(w, cx, item, containing_item);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("<code>");
assoc_const(
w,
item,
@ -1424,21 +1415,14 @@ fn render_impl(
cx,
);
w.write_str("</code>");
render_stability_since_raw(
w,
item.stable_since(tcx).as_deref(),
item.const_stable_since(tcx).as_deref(),
outer_version,
outer_const_version,
);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write_srclink(cx, item, w);
w.write_str("</div>");
}
clean::AssocTypeItem(ref bounds, ref default) => {
let source_id = format!("{}.{}", item_type, name);
let id = cx.derive_id(source_id.clone());
write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
write!(w, "<div id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("<code>");
assoc_type(
w,
item,
@ -1449,7 +1433,6 @@ fn render_impl(
cx,
);
w.write_str("</code>");
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
w.write_str("</div>");
}
clean::StrippedItem(..) => return,
@ -1474,11 +1457,10 @@ fn render_impl(
cx,
trait_item,
if trait_.is_some() { &i.impl_item } else { parent },
parent,
link,
render_mode,
false,
outer_version,
outer_const_version,
trait_.map(|t| &t.trait_),
show_def_docs,
);
@ -1491,9 +1473,8 @@ fn render_impl(
t: &clean::Trait,
i: &clean::Impl,
parent: &clean::Item,
containing_item: &clean::Item,
render_mode: RenderMode,
outer_version: Option<&str>,
outer_const_version: Option<&str>,
show_def_docs: bool,
) {
for trait_item in &t.items {
@ -1511,11 +1492,10 @@ fn render_impl(
cx,
trait_item,
parent,
containing_item,
assoc_link,
render_mode,
true,
outer_version,
outer_const_version,
Some(t),
show_def_docs,
);
@ -1535,28 +1515,25 @@ fn render_impl(
&t.trait_,
&i.inner_impl(),
&i.impl_item,
parent,
render_mode,
outer_version,
outer_const_version,
show_def_docs,
);
}
}
if render_mode == RenderMode::Normal {
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
let toggled = !(impl_items.is_empty() && default_impl_items.is_empty());
if toggled {
close_tags.insert_str(0, "</details>");
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
}
if toggled {
write!(w, "<summary>")
}
render_impl_summary(
w,
cx,
i,
outer_version,
outer_const_version,
parent,
parent,
show_def_docs,
use_absolute,
is_on_foreign_type,
@ -1565,11 +1542,6 @@ fn render_impl(
if toggled {
write!(w, "</summary>")
}
if trait_.is_some() {
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
write!(w, "<div class=\"item-info\">{}</div>", portability);
}
}
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
let mut ids = cx.id_map.borrow_mut();
@ -1597,12 +1569,35 @@ fn render_impl(
w.write_str(&close_tags);
}
fn render_impl_summary(
// Render the items that appear on the right side of methods, impls, and
// associated types. For example "1.0.0 (const: 1.39.0) [src]".
fn render_rightside(
w: &mut Buffer,
cx: &Context<'_>,
item: &clean::Item,
containing_item: &clean::Item,
) {
let tcx = cx.tcx();
write!(w, "<div class=\"rightside\">");
render_stability_since_raw(
w,
item.stable_since(tcx).as_deref(),
item.const_stable_since(tcx).as_deref(),
containing_item.stable_since(tcx).as_deref(),
containing_item.const_stable_since(tcx).as_deref(),
);
write_srclink(cx, item, w);
w.write_str("</div>");
}
pub(crate) fn render_impl_summary(
w: &mut Buffer,
cx: &Context<'_>,
i: &Impl,
outer_version: Option<&str>,
outer_const_version: Option<&str>,
parent: &clean::Item,
containing_item: &clean::Item,
show_def_docs: bool,
use_absolute: Option<bool>,
is_on_foreign_type: bool,
@ -1610,7 +1605,6 @@ fn render_impl_summary(
// in documentation pages for trait with automatic implementations like "Send" and "Sync".
aliases: &[String],
) {
let tcx = cx.tcx();
let id = cx.derive_id(match i.inner_impl().trait_ {
Some(ref t) => {
if is_on_foreign_type {
@ -1626,13 +1620,12 @@ fn render_impl_summary(
} else {
format!(" data-aliases=\"{}\"", aliases.join(","))
};
write!(w, "<div id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
render_rightside(w, cx, &i.impl_item, containing_item);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<code class=\"in-band\">");
if let Some(use_absolute) = use_absolute {
write!(
w,
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
<code class=\"in-band\">",
id, aliases
);
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
if show_def_docs {
for it in &i.inner_impl().items {
@ -1643,26 +1636,18 @@ fn render_impl_summary(
}
}
}
w.write_str("</code>");
} else {
write!(
w,
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
<code class=\"in-band\">{}</code>",
id,
aliases,
i.inner_impl().print(false, cx)
);
write!(w, "{}", i.inner_impl().print(false, cx));
}
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
render_stability_since_raw(
w,
i.impl_item.stable_since(tcx).as_deref(),
i.impl_item.const_stable_since(tcx).as_deref(),
outer_version,
outer_const_version,
);
write_srclink(cx, &i.impl_item, w);
write!(w, "</code>");
let is_trait = i.inner_impl().trait_.is_some();
if is_trait {
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
write!(w, "<div class=\"item-info\">{}</div>", portability);
}
}
w.write_str("</div>");
}

View file

@ -15,7 +15,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
use super::{
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
render_impl, render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink,
Context,
};
use crate::clean::{self, GetDefId};
use crate::formats::item_type::ItemType;
@ -585,11 +586,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
if toggled {
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
}
write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
w.write_str("</code>");
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
write!(w, "<div class=\"rightside\">");
render_stability_since(w, m, t, cx.tcx());
write_srclink(cx, m, w);
write!(w, "</div>");
write!(w, "<code>");
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
w.write_str("</code>");
w.write_str("</div>");
if toggled {
write!(w, "</summary>");
@ -701,8 +705,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
it,
assoc_link,
RenderMode::Normal,
implementor.impl_item.stable_since(cx.tcx()).as_deref(),
implementor.impl_item.const_stable_since(cx.tcx()).as_deref(),
false,
None,
true,
@ -1310,7 +1312,7 @@ fn render_implementor(
implementor_dups: &FxHashMap<Symbol, (DefId, bool)>,
aliases: &[String],
) {
// If there's already another implementor that has the same abbridged name, use the
// If there's already another implementor that has the same abridged name, use the
// full path, for example in `std::iter::ExactSizeIterator`
let use_absolute = match implementor.inner_impl().for_ {
clean::ResolvedPath { ref path, is_generic: false, .. }
@ -1320,19 +1322,15 @@ fn render_implementor(
} => implementor_dups[&path.last()].1,
_ => false,
};
render_impl(
render_impl_summary(
w,
cx,
implementor,
trait_,
AssocItemLink::Anchor(None),
RenderMode::Normal,
trait_.stable_since(cx.tcx()).as_deref(),
trait_.const_stable_since(cx.tcx()).as_deref(),
trait_,
false,
Some(use_absolute),
false,
false,
aliases,
);
}

View file

@ -778,7 +778,6 @@ function hideThemeButtonState() {
}
var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
var hideImplementations = getSettingValue("auto-hide-trait-implementations") === "true";
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
@ -796,10 +795,6 @@ function hideThemeButtonState() {
setImplementorsTogglesOpen("blanket-implementations-list", false);
}
if (!hideImplementors) {
setImplementorsTogglesOpen("implementors-list", true);
}
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) {
e.open = true;

View file

@ -581,7 +581,6 @@ nav.sub {
.content .item-info {
position: relative;
margin-left: 33px;
margin-top: -13px;
}
.sub-variant > div > .item-info {
@ -852,12 +851,12 @@ body.blur > :not(#help) {
}
.stab {
display: table;
border-width: 1px;
border-style: solid;
padding: 3px;
margin-bottom: 5px;
font-size: 90%;
font-weight: normal;
}
.stab p {
display: inline;
@ -900,32 +899,25 @@ body.blur > :not(#help) {
.since {
font-weight: normal;
font-size: initial;
position: absolute;
right: 0;
top: 0;
}
.impl-items .since, .impl .since, .methods .since {
flex-grow: 0;
padding-left: 12px;
padding-right: 2px;
position: initial;
}
.impl-items .srclink, .impl .srclink, .methods .srclink {
flex-grow: 0;
/* Override header settings otherwise it's too bold */
font-size: 17px;
font-weight: normal;
}
.impl-items code, .impl code, .methods code {
flex-grow: 1;
.rightside {
float: right;
}
.has-srclink {
display: flex;
flex-basis: 100%;
font-size: 16px;
margin-bottom: 12px;
/* Push the src link out to the right edge consistently */
@ -986,7 +978,6 @@ a.test-arrow:hover{
}
.since + .srclink {
display: table-cell;
padding-left: 10px;
}
@ -1046,6 +1037,10 @@ a.test-arrow:hover{
opacity: 1;
}
:target {
padding-right: 3px;
}
.information {
position: absolute;
left: -25px;
@ -1612,11 +1607,6 @@ details.undocumented[open] > summary::before {
margin-left: 0;
}
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
.impl-items > .associatedtype {
display: flex;
}
.anchor {
display: none !important;
}

View file

@ -334,8 +334,11 @@ a.test-arrow:hover {
color: #999;
}
:target > code, :target > .in-band {
:target, :target * {
background: rgba(255, 236, 164, 0.06);
}
:target {
border-right: 3px solid rgba(255, 180, 76, 0.85);
}

View file

@ -282,8 +282,11 @@ a.test-arrow:hover{
color: #999;
}
:target > code, :target > .in-band {
:target, :target * {
background-color: #494a3d;
}
:target {
border-right: 3px solid #bb7410;
}

View file

@ -275,8 +275,11 @@ a.test-arrow:hover{
color: #999;
}
:target > code, :target > .in-band {
:target, :target * {
background: #FDFFD3;
}
:target {
border-right: 3px solid #ffb44c;
}

View file

@ -2,9 +2,6 @@
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow
// In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)".
assert: ("#blanket-implementations-list > details:nth-child(2)", "open", "")
// Please note the "\" below is needed because otherwise ".borrow" would be interpreted as
// a class selector.
assert: ("#method\.borrow", {"display": "flex"})
// We first check that the impl block is open by default.
assert: ("#implementations + details", "open", "")
// We collapse it.

View file

@ -2,5 +2,5 @@
// This test ensures that the [src] link is present on traits items.
// @has foo/trait.Iterator.html '//div[@id="method.zip"]/a[@class="srclink"]' "[src]"
// @has foo/trait.Iterator.html '//div[@id="method.zip"]//a[@class="srclink"]' "[src]"
pub use std::iter::Iterator;

View file

@ -1,20 +0,0 @@
// @has issue_19055/trait.Any.html
pub trait Any {}
impl<'any> Any + 'any {
// @has - '//*[@id="method.is"]' 'fn is'
pub fn is<T: 'static>(&self) -> bool { loop {} }
// @has - '//*[@id="method.downcast_ref"]' 'fn downcast_ref'
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> { loop {} }
// @has - '//*[@id="method.downcast_mut"]' 'fn downcast_mut'
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> { loop {} }
}
pub trait Foo {
fn foo(&self) {}
}
// @has - '//*[@id="method.foo"]' 'fn foo'
impl Foo for Any {}

View file

@ -2,11 +2,11 @@
// @has foo/struct.Unsized.html
// @has - '//div[@id="impl-Sized"]/code' 'impl !Sized for Unsized'
// @!has - '//div[@id="impl-Sized"]/a[@class="srclink"]' '[src]'
// @!has - '//div[@id="impl-Sized"]//a[@class="srclink"]' '[src]'
// @has - '//div[@id="impl-Sync"]/code' 'impl Sync for Unsized'
// @!has - '//div[@id="impl-Sync"]/a[@class="srclink"]' '[src]'
// @!has - '//div[@id="impl-Sync"]//a[@class="srclink"]' '[src]'
// @has - '//div[@id="impl-Any"]/code' 'impl<T> Any for T'
// @has - '//div[@id="impl-Any"]/a[@class="srclink"]' '[src]'
// @has - '//div[@id="impl-Any"]//a[@class="srclink"]' '[src]'
pub struct Unsized {
data: [u8],
}

View file

@ -38,23 +38,15 @@ impl MyTrait for Vec<u8> {
}
impl MyTrait for MyStruct {
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="type"]/@href' #associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc
type Assoc = bool;
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="constant"]/@href' #associatedconstant.VALUE
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE
const VALUE: u32 = 20;
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="fnname"]/@href' #tymethod.trait_function
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="anchor"]/@href' #method.trait_function-2
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="fnname"]/@href' trait.MyTrait.html#tymethod.trait_function
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function
fn trait_function(&self) {}
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="fnname"]/@href' #method.defaulted_override
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="anchor"]/@href' #method.defaulted_override-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="fnname"]/@href' trait.MyTrait.html#method.defaulted_override
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override
fn defaulted_override(&self) {}