Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] rustdoc-x-crate-src-aware-pred-cleaning #15

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ where
self.cx,
tcx.generics_of(item_def_id),
ty::GenericPredicates::default(),
item_def_id,
);
let params = raw_generics.params;

Expand Down Expand Up @@ -456,6 +457,7 @@ where
self.cx,
tcx.generics_of(item_def_id),
tcx.explicit_predicates_of(item_def_id),
item_def_id,
);
let mut generic_params = raw_generics.params;

Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
cx,
cx.tcx.generics_of(impl_def_id),
cx.tcx.explicit_predicates_of(impl_def_id),
impl_def_id,
),
// FIXME(eddyb) compute both `trait_` and `for_` from
// the post-inference `trait_ref`, as it's more accurate.
Expand Down
33 changes: 22 additions & 11 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
.collect();

let predicates = cx.tcx.predicates_of(did);
let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates, did);
let generics = filter_non_trait_generics(did, generics);
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
clean::Trait { def_id: did, generics, items: trait_items, bounds: supertrait_bounds }
Expand All @@ -282,8 +282,12 @@ pub(crate) fn build_function<'tcx>(
) -> Box<clean::Function> {
let sig = cx.tcx.fn_sig(def_id).instantiate_identity();
// The generics need to be cleaned before the signature.
let mut generics =
clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id));
let mut generics = clean_ty_generics(
cx,
cx.tcx.generics_of(def_id),
cx.tcx.explicit_predicates_of(def_id),
def_id,
);
let bound_vars = clean_bound_vars(sig.bound_vars());

// At the time of writing early & late-bound params are stored separately in rustc,
Expand All @@ -306,6 +310,9 @@ pub(crate) fn build_function<'tcx>(
generics.params.sort_by_key(|param| cx.tcx.def_ident_span(param.def_id).unwrap());
}

// FIXME(fmease): @Temporary
crate::clean::simplify::move_bounds_to_generic_parameters(&mut generics);

let decl = clean_poly_fn_sig(cx, Some(def_id), sig);

Box::new(clean::Function { decl, generics })
Expand All @@ -315,7 +322,7 @@ fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum {
let predicates = cx.tcx.explicit_predicates_of(did);

clean::Enum {
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates, did),
variants: cx.tcx.adt_def(did).variants().iter().map(|v| clean_variant_def(v, cx)).collect(),
}
}
Expand All @@ -326,7 +333,7 @@ fn build_struct(cx: &mut DocContext<'_>, did: DefId) -> clean::Struct {

clean::Struct {
ctor_kind: variant.ctor_kind(),
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates, did),
fields: variant.fields.iter().map(|x| clean_middle_field(x, cx)).collect(),
}
}
Expand All @@ -335,7 +342,7 @@ fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union {
let predicates = cx.tcx.explicit_predicates_of(did);
let variant = cx.tcx.adt_def(did).non_enum_variant();

let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates, did);
let fields = variant.fields.iter().map(|x| clean_middle_field(x, cx)).collect();
clean::Union { generics, fields }
}
Expand All @@ -352,7 +359,7 @@ fn build_type_alias(

Box::new(clean::TypeAlias {
type_,
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates, did),
inner_type,
item_type: None,
})
Expand Down Expand Up @@ -530,7 +537,7 @@ pub(crate) fn build_impl(
})
.map(|item| clean_impl_item(item, cx))
.collect::<Vec<_>>(),
clean_generics(impl_.generics, cx),
clean_generics(impl_.generics, cx, did),
),
None => (
tcx.associated_items(did)
Expand Down Expand Up @@ -558,7 +565,7 @@ pub(crate) fn build_impl(
.map(|item| clean_middle_assoc_item(item, cx))
.collect::<Vec<_>>(),
clean::enter_impl_trait(cx, |cx| {
clean_ty_generics(cx, tcx.generics_of(did), predicates)
clean_ty_generics(cx, tcx.generics_of(did), predicates, did)
}),
),
};
Expand Down Expand Up @@ -716,8 +723,12 @@ pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
}

fn build_const(cx: &mut DocContext<'_>, def_id: DefId) -> clean::Constant {
let mut generics =
clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id));
let mut generics = clean_ty_generics(
cx,
cx.tcx.generics_of(def_id),
cx.tcx.explicit_predicates_of(def_id),
def_id,
);
clean::simplify::move_bounds_to_generic_parameters(&mut generics);

clean::Constant {
Expand Down
Loading