mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-07 04:38:46 +00:00
Auto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514
Restore linking to itself in implementors section of trait page Reverts #32558 as proposed in [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Trait.20implementation.20self-links/near/223773273) r? `@jyn514` cc `@camelid`
This commit is contained in:
commit
921ec4b3fc
@ -102,14 +102,6 @@ impl Buffer {
|
|||||||
self.into_inner()
|
self.into_inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn from_display<T: std::fmt::Display>(&mut self, t: T) {
|
|
||||||
if self.for_html {
|
|
||||||
write!(self, "{}", t);
|
|
||||||
} else {
|
|
||||||
write!(self, "{:#}", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
crate fn is_for_html(&self) -> bool {
|
crate fn is_for_html(&self) -> bool {
|
||||||
self.for_html
|
self.for_html
|
||||||
}
|
}
|
||||||
@ -900,16 +892,7 @@ impl clean::Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl clean::Impl {
|
impl clean::Impl {
|
||||||
crate fn print<'a>(&'a self, cache: &'a Cache) -> impl fmt::Display + 'a {
|
crate fn print<'a>(&'a self, cache: &'a Cache, use_absolute: bool) -> impl fmt::Display + 'a {
|
||||||
self.print_inner(true, false, cache)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn print_inner<'a>(
|
|
||||||
&'a self,
|
|
||||||
link_trait: bool,
|
|
||||||
use_absolute: bool,
|
|
||||||
cache: &'a Cache,
|
|
||||||
) -> impl fmt::Display + 'a {
|
|
||||||
display_fn(move |f| {
|
display_fn(move |f| {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "impl{:#} ", self.generics.print(cache))?;
|
write!(f, "impl{:#} ", self.generics.print(cache))?;
|
||||||
@ -921,21 +904,7 @@ impl clean::Impl {
|
|||||||
if self.negative_polarity {
|
if self.negative_polarity {
|
||||||
write!(f, "!")?;
|
write!(f, "!")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if link_trait {
|
|
||||||
fmt::Display::fmt(&ty.print(cache), f)?;
|
fmt::Display::fmt(&ty.print(cache), f)?;
|
||||||
} else {
|
|
||||||
match ty {
|
|
||||||
clean::ResolvedPath {
|
|
||||||
param_names: None, path, is_generic: false, ..
|
|
||||||
} => {
|
|
||||||
let last = path.segments.last().unwrap();
|
|
||||||
fmt::Display::fmt(&last.name, f)?;
|
|
||||||
fmt::Display::fmt(&last.args.print(cache), f)?;
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
write!(f, " for ")?;
|
write!(f, " for ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,16 +921,6 @@ impl clean::Impl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The difference from above is that trait is not hyperlinked.
|
|
||||||
crate fn fmt_impl_for_trait_page(
|
|
||||||
i: &clean::Impl,
|
|
||||||
f: &mut Buffer,
|
|
||||||
use_absolute: bool,
|
|
||||||
cache: &Cache,
|
|
||||||
) {
|
|
||||||
f.from_display(i.print_inner(false, use_absolute, cache))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl clean::Arguments {
|
impl clean::Arguments {
|
||||||
crate fn print<'a>(&'a self, cache: &'a Cache) -> impl fmt::Display + 'a {
|
crate fn print<'a>(&'a self, cache: &'a Cache) -> impl fmt::Display + 'a {
|
||||||
display_fn(move |f| {
|
display_fn(move |f| {
|
||||||
|
@ -73,7 +73,6 @@ use crate::formats::cache::Cache;
|
|||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
use crate::formats::{AssocItemRender, FormatRenderer, Impl, RenderMode};
|
use crate::formats::{AssocItemRender, FormatRenderer, Impl, RenderMode};
|
||||||
use crate::html::escape::Escape;
|
use crate::html::escape::Escape;
|
||||||
use crate::html::format::fmt_impl_for_trait_page;
|
|
||||||
use crate::html::format::Function;
|
use crate::html::format::Function;
|
||||||
use crate::html::format::{href, print_default_space, print_generic_bounds, WhereClause};
|
use crate::html::format::{href, print_default_space, print_generic_bounds, WhereClause};
|
||||||
use crate::html::format::{print_abi_with_space, Buffer, PrintWithSpace};
|
use crate::html::format::{print_abi_with_space, Buffer, PrintWithSpace};
|
||||||
@ -1138,7 +1137,7 @@ themePicker.onblur = handleThemeButtonsBlur;
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Implementor {
|
Some(Implementor {
|
||||||
text: imp.inner_impl().print(cx.cache()).to_string(),
|
text: imp.inner_impl().print(cx.cache(), false).to_string(),
|
||||||
synthetic: imp.inner_impl().synthetic,
|
synthetic: imp.inner_impl().synthetic,
|
||||||
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cx.cache()),
|
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cx.cache()),
|
||||||
})
|
})
|
||||||
@ -2550,8 +2549,8 @@ fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cache: &Cache) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl, cache: &Cache) -> Ordering {
|
fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl, cache: &Cache) -> Ordering {
|
||||||
let lhs = format!("{}", lhs.inner_impl().print(cache));
|
let lhs = format!("{}", lhs.inner_impl().print(cache, false));
|
||||||
let rhs = format!("{}", rhs.inner_impl().print(cache));
|
let rhs = format!("{}", rhs.inner_impl().print(cache, false));
|
||||||
|
|
||||||
// lhs and rhs are formatted as HTML, which may be unnecessary
|
// lhs and rhs are formatted as HTML, which may be unnecessary
|
||||||
compare_names(&lhs, &rhs)
|
compare_names(&lhs, &rhs)
|
||||||
@ -3698,7 +3697,7 @@ fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache) -> String {
|
|||||||
write!(
|
write!(
|
||||||
&mut out,
|
&mut out,
|
||||||
"<span class=\"where fmt-newline\">{}</span>",
|
"<span class=\"where fmt-newline\">{}</span>",
|
||||||
impl_.print(cache)
|
impl_.print(cache, false)
|
||||||
);
|
);
|
||||||
let t_did = impl_.trait_.def_id_full(cache).unwrap();
|
let t_did = impl_.trait_.def_id_full(cache).unwrap();
|
||||||
for it in &impl_.items {
|
for it in &impl_.items {
|
||||||
@ -3771,7 +3770,7 @@ fn render_impl(
|
|||||||
};
|
};
|
||||||
if let Some(use_absolute) = use_absolute {
|
if let Some(use_absolute) = use_absolute {
|
||||||
write!(w, "<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">", id, aliases);
|
write!(w, "<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">", id, aliases);
|
||||||
fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute, cx.cache());
|
write!(w, "{}", i.inner_impl().print(cx.cache(), use_absolute));
|
||||||
if show_def_docs {
|
if show_def_docs {
|
||||||
for it in &i.inner_impl().items {
|
for it in &i.inner_impl().items {
|
||||||
if let clean::TypedefItem(ref tydef, _) = *it.kind {
|
if let clean::TypedefItem(ref tydef, _) = *it.kind {
|
||||||
@ -3796,7 +3795,7 @@ fn render_impl(
|
|||||||
"<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
"<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
||||||
id,
|
id,
|
||||||
aliases,
|
aliases,
|
||||||
i.inner_impl().print(cx.cache())
|
i.inner_impl().print(cx.cache(), false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// @!has trait_self_link/trait.Foo.html //a/@href ../trait_self_link/trait.Foo.html
|
// @has trait_self_link/trait.Foo.html //a/@href ../trait_self_link/trait.Foo.html
|
||||||
pub trait Foo {}
|
pub trait Foo {}
|
||||||
|
|
||||||
pub struct Bar;
|
pub struct Bar;
|
||||||
|
Loading…
Reference in New Issue
Block a user