Fix inlining

This commit is contained in:
Aaron Hill 2018-02-15 18:45:52 -05:00
parent 94fd4f360b
commit 64a1f6fbfd
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
2 changed files with 15 additions and 5 deletions

View File

@ -2451,6 +2451,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
<ul class='item-list' id='synthetic-implementors-list'>
";
let mut synthetic_types = Vec::new();
if let Some(implementors) = 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.
@ -2506,6 +2508,9 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
if t.auto {
write!(w, "{}", synthetic_impl_header)?;
for implementor in synthetic {
synthetic_types.extend(
collect_paths_for_type(implementor.inner_impl().for_.clone())
);
render_implementor(cx, implementor, w, &implementor_dups)?;
}
write!(w, "</ul>")?;
@ -2516,13 +2521,13 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
write!(w, "{}", impl_header)?;
write!(w, "</ul>")?;
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set();</script>"#)?;
if t.auto {
write!(w, "{}", synthetic_impl_header)?;
write!(w, "</ul>")?;
}
}
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
as_json(&synthetic_types))?;
write!(w, r#"<script type="text/javascript" async
src="{root_path}/implementors/{path}/{ty}.{name}.js">

View File

@ -1565,6 +1565,7 @@
window.register_implementors = function(imp) {
var implementors = document.getElementById('implementors-list');
var synthetic_implementors = document.getElementById('synthetic-implementors-list');
var libs = Object.getOwnPropertyNames(imp);
for (var i = 0; i < libs.length; ++i) {
if (libs[i] === currentCrate) { continue; }
@ -1573,12 +1574,16 @@
struct_loop:
for (var j = 0; j < structs.length; ++j) {
var struct = structs[j];
var list = struct.synthetic ? synthetic_implementors : implementors;
if (struct.synthetic) {
for (var k = 0; k < struct.types.length; k++) {
if (window.inlined_types.has(struct.types[k])) {
continue struct_loop;
}
window.inlined_types.add(struct.types[k]);
}
}
var code = document.createElement('code');