hash the contents of impl-item-ref by adding them to visitor

Also simplify some of the `ty::AssociatedItem` representation,
in particular by folding `has_value` into `hir::Defaultness`
This commit is contained in:
Niko Matsakis 2016-11-14 11:00:02 -05:00
parent c17be9ea11
commit b10b98169f
17 changed files with 234 additions and 55 deletions

View file

@ -364,7 +364,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
let trait_items = tcx.associated_items(did).filter_map(|item| {
match item.kind {
ty::AssociatedKind::Const => {
let default = if item.has_value {
let default = if item.defaultness.has_value() {
Some(pprust::expr_to_string(
lookup_const_by_id(tcx, item.def_id, None).unwrap().0))
} else {
@ -407,7 +407,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
abi: abi
})
}
_ => panic!("not a tymethod"),
ref r => panic!("not a tymethod: {:?}", r),
};
Some(cleaned)
}

View file

@ -1373,9 +1373,10 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
}
}
}
let provided = match self.container {
ty::ImplContainer(_) => false,
ty::TraitContainer(_) => self.has_value
ty::TraitContainer(_) => self.defaultness.has_value()
};
if provided {
MethodItem(Method {
@ -1440,7 +1441,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
None => bounds.push(TyParamBound::maybe_sized(cx)),
}
let ty = if self.has_value {
let ty = if self.defaultness.has_value() {
Some(cx.tcx().item_type(self.def_id))
} else {
None