writeln!(v, "{}", *implementor).unwrap();
}
v.push_str(
- r"
- if (window.register_implementors) {
- window.register_implementors(implementors);
- } else {
- window.pending_implementors = implementors;
- }
- ",
+ "if (window.register_implementors) {\
+ window.register_implementors(implementors);\
+ } else {\
+ window.pending_implementors = implementors;\
+ }",
);
v.push_str("})()");
cx.shared.fs.write(&mydst, &v)?;
"{}{}{}{}{:#}fn {}{:#}",
it.visibility.print_with_space(),
f.header.constness.print_with_space(),
- f.header.unsafety.print_with_space(),
f.header.asyncness.print_with_space(),
+ f.header.unsafety.print_with_space(),
print_abi_with_space(f.header.abi),
it.name.as_ref().unwrap(),
f.generics.print()
render_attributes(w, it, false);
write!(
w,
- "{vis}{constness}{unsafety}{asyncness}{abi}fn \
+ "{vis}{constness}{asyncness}{unsafety}{abi}fn \
{name}{generics}{decl}{where_clause}</pre>",
vis = it.visibility.print_with_space(),
constness = f.header.constness.print_with_space(),
- unsafety = f.header.unsafety.print_with_space(),
asyncness = f.header.asyncness.print_with_space(),
+ unsafety = f.header.unsafety.print_with_space(),
abi = print_abi_with_space(f.header.abi),
name = it.name.as_ref().unwrap(),
generics = f.generics.print(),
implementor: &Impl,
w: &mut Buffer,
implementor_dups: &FxHashMap<&str, (DefId, bool)>,
+ aliases: &[String],
) {
// If there's already another implementor that has the same abbridged name, use the
// full path, for example in `std::iter::ExactSizeIterator`
Some(use_absolute),
false,
false,
+ aliases,
);
}
None,
false,
true,
+ &[],
);
buffer.into_inner()
})
// If there are methods directly on this trait object, render them here.
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All);
- let mut synthetic_types = Vec::new();
-
if let Some(implementors) = cx.cache.implementors.get(&it.def_id) {
// The DefId is for the first Type found with that name. The bool is
// if any Types with the same name but different DefId have been found.
None,
true,
false,
+ &[],
);
}
write_loading_content(w, "");
"<div class='item-list' id='implementors-list'>",
);
for implementor in concrete {
- render_implementor(cx, implementor, w, &implementor_dups);
+ render_implementor(cx, implementor, w, &implementor_dups, &[]);
}
write_loading_content(w, "</div>");
"<div class='item-list' id='synthetic-implementors-list'>",
);
for implementor in synthetic {
- synthetic_types
- .extend(collect_paths_for_type(implementor.inner_impl().for_.clone()));
- render_implementor(cx, implementor, w, &implementor_dups);
+ render_implementor(
+ cx,
+ implementor,
+ w,
+ &implementor_dups,
+ &collect_paths_for_type(implementor.inner_impl().for_.clone()),
+ );
}
write_loading_content(w, "</div>");
}
write_loading_content(w, "</div>");
}
}
- write!(
- w,
- r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
- serde_json::to_string(&synthetic_types).unwrap(),
- );
write!(
w,
- r#"<script type="text/javascript" async
- src="{root_path}/implementors/{path}/{ty}.{name}.js">
- </script>"#,
+ "<script type=\"text/javascript\" \
+ src=\"{root_path}/implementors/{path}/{ty}.{name}.js\" async>\
+ </script>",
root_path = vec![".."; cx.current.len()].join("/"),
path = if it.def_id.is_local() {
cx.current.join("/")
"{}{}{}{}{}{:#}fn {}{:#}",
meth.visibility.print_with_space(),
header.constness.print_with_space(),
- header.unsafety.print_with_space(),
header.asyncness.print_with_space(),
+ header.unsafety.print_with_space(),
print_default_space(meth.is_default()),
print_abi_with_space(header.abi),
name,
if parent == ItemType::Trait { " " } else { "" },
meth.visibility.print_with_space(),
header.constness.print_with_space(),
- header.unsafety.print_with_space(),
header.asyncness.print_with_space(),
+ header.unsafety.print_with_space(),
print_default_space(meth.is_default()),
print_abi_with_space(header.abi),
href = href,
None,
false,
true,
+ &[],
);
}
}
deref_mut: bool,
) {
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
- let target = impl_
+ let (target, real_target) = impl_
.inner_impl()
.items
.iter()
.filter_map(|item| match item.inner {
- clean::TypedefItem(ref t, true) => Some(&t.type_),
+ clean::TypedefItem(ref t, true) => Some(match *t {
+ clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
+ _ => (&t.type_, &t.type_),
+ }),
_ => None,
})
.next()
.expect("Expected associated type binding");
let what =
- AssocItemRender::DerefFor { trait_: deref_type, type_: target, deref_mut_: deref_mut };
+ AssocItemRender::DerefFor { trait_: deref_type, type_: real_target, deref_mut_: deref_mut };
if let Some(did) = target.def_id() {
- render_assoc_items(w, cx, container_item, did, what)
+ render_assoc_items(w, cx, container_item, did, what);
} else {
if let Some(prim) = target.primitive_type() {
if let Some(&did) = cx.cache.primitive_locations.get(&prim) {
use_absolute: Option<bool>,
is_on_foreign_type: bool,
show_default_items: bool,
+ // This argument is used to reference same type with different pathes to avoid duplication
+ // in documentation pages for trait with automatic implementations like "Send" and "Sync".
+ aliases: &[String],
) {
if render_mode == RenderMode::Normal {
let id = cx.derive_id(match i.inner_impl().trait_ {
}
None => "impl".to_string(),
});
+ let aliases = if aliases.is_empty() {
+ String::new()
+ } else {
+ format!(" aliases=\"{}\"", aliases.join(","))
+ };
if let Some(use_absolute) = use_absolute {
- write!(w, "<h3 id='{}' class='impl'><code class='in-band'>", id);
+ write!(w, "<h3 id='{}' class='impl'{}><code class='in-band'>", id, aliases);
fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute);
if show_def_docs {
for it in &i.inner_impl().items {
} else {
write!(
w,
- "<h3 id='{}' class='impl'><code class='in-band'>{}</code>",
+ "<h3 id='{}' class='impl'{}><code class='in-band'>{}</code>",
id,
+ aliases,
i.inner_impl().print()
);
}
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did)
{
- if let Some(target) = impl_
+ if let Some((target, real_target)) = impl_
.inner_impl()
.items
.iter()
.filter_map(|item| match item.inner {
- clean::TypedefItem(ref t, true) => Some(&t.type_),
+ clean::TypedefItem(ref t, true) => Some(match *t {
+ clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
+ _ => (&t.type_, &t.type_),
+ }),
_ => None,
})
.next()
"{:#}",
impl_.inner_impl().trait_.as_ref().unwrap().print()
)),
- Escape(&format!("{:#}", target.print()))
+ Escape(&format!("{:#}", real_target.print()))
));
out.push_str("</a>");
let mut ret = impls