self.type_() == ItemType::Variant
}
pub fn is_associated_type(&self) -> bool {
- self.type_() == ItemType::AssociatedType
+ self.type_() == ItemType::AssocType
}
pub fn is_associated_const(&self) -> bool {
- self.type_() == ItemType::AssociatedConst
+ self.type_() == ItemType::AssocConst
}
pub fn is_method(&self) -> bool {
self.type_() == ItemType::Method
MacroItem(Macro),
ProcMacroItem(ProcMacro),
PrimitiveItem(PrimitiveType),
- AssociatedConstItem(Type, Option<String>),
- AssociatedTypeItem(Vec<GenericBound>, Option<Type>),
+ AssocConstItem(Type, Option<String>),
+ AssocTypeItem(Vec<GenericBound>, Option<Type>),
/// An item that has been stripped by a rustdoc pass
StrippedItem(Box<ItemEnum>),
KeywordItem(String),
pub fn is_associated(&self) -> bool {
match *self {
ItemEnum::TypedefItem(_, _) |
- ItemEnum::AssociatedTypeItem(_, _) => true,
+ ItemEnum::AssocTypeItem(_, _) => true,
_ => false,
}
}
Arguments {
values: self.0.iter().enumerate().map(|(i, ty)| {
+ let original_pat = cx.tcx.hir().original_pat_of_argument(&body.arguments[i]);
Argument {
- name: name_from_pat(&body.arguments[i].original_pat()),
+ name: name_from_pat(original_pat),
type_: ty.clean(cx),
}
}).collect()
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.node {
hir::TraitItemKind::Const(ref ty, default) => {
- AssociatedConstItem(ty.clean(cx),
+ AssocConstItem(ty.clean(cx),
default.map(|e| print_const_expr(cx, e)))
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
})
}
hir::TraitItemKind::Type(ref bounds, ref default) => {
- AssociatedTypeItem(bounds.clean(cx), default.clean(cx))
+ AssocTypeItem(bounds.clean(cx), default.clean(cx))
}
};
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.node {
hir::ImplItemKind::Const(ref ty, expr) => {
- AssociatedConstItem(ty.clean(cx),
+ AssocConstItem(ty.clean(cx),
Some(print_const_expr(cx, expr)))
}
hir::ImplItemKind::Method(ref sig, body) => {
}
}
-impl<'tcx> Clean<Item> for ty::AssociatedItem {
+impl<'tcx> Clean<Item> for ty::AssocItem {
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.kind {
- ty::AssociatedKind::Const => {
+ ty::AssocKind::Const => {
let ty = cx.tcx.type_of(self.def_id);
let default = if self.defaultness.has_value() {
Some(inline::print_inlined_const(cx, self.def_id))
} else {
None
};
- AssociatedConstItem(ty.clean(cx), default)
+ AssocConstItem(ty.clean(cx), default)
}
- ty::AssociatedKind::Method => {
+ ty::AssocKind::Method => {
let generics = (cx.tcx.generics_of(self.def_id),
&cx.tcx.explicit_predicates_of(self.def_id)).clean(cx);
let sig = cx.tcx.fn_sig(self.def_id);
})
}
}
- ty::AssociatedKind::Type => {
+ ty::AssocKind::Type => {
let my_name = self.ident.name.clean(cx);
if let ty::TraitContainer(did) = self.container {
None
};
- AssociatedTypeItem(bounds, ty.clean(cx))
+ AssocTypeItem(bounds, ty.clean(cx))
} else {
TypedefItem(Typedef {
type_: cx.tcx.type_of(self.def_id).clean(cx),
}, true)
}
}
- ty::AssociatedKind::Existential => unimplemented!(),
+ ty::AssocKind::Existential => unimplemented!(),
};
let visibility = match self.container {
ty::Str => Primitive(PrimitiveType::Str),
ty::Slice(ty) => Slice(box ty.clean(cx)),
ty::Array(ty, n) => {
- let mut n = *cx.tcx.lift(&n).expect("array lift failed");
+ let mut n = cx.tcx.lift(&n).expect("array lift failed");
if let ConstValue::Unevaluated(def_id, substs) = n.val {
let param_env = cx.tcx.param_env(def_id);
let cid = GlobalId {
fn clean(&self, cx: &DocContext<'_>) -> Constant {
Constant {
type_: self.ty.clean(cx),
- expr: match self.val {
- ConstValue::Param(ty::ParamConst { name, .. }) => format!("{}", name),
- e => format!("{:?}", e), // FIXME generic consts with expressions
- },
+ expr: format!("{}", self),
}
}
}
}
}
-fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
+fn print_const(cx: &DocContext<'_>, n: &ty::Const<'_>) -> String {
match n.val {
ConstValue::Unevaluated(def_id, _) => {
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
}
},
_ => {
- let mut s = String::new();
- ::rustc::mir::fmt_const_val(&mut s, n).expect("fmt_const_val failed");
+ let mut s = n.to_string();
// array lengths are obviously usize
if s.ends_with("usize") {
let n = s.len() - "usize".len();
s.truncate(n);
+ if s.ends_with(": ") {
+ let n = s.len() - ": ".len();
+ s.truncate(n);
+ }
}
s
},
}
Res::SelfTy(..)
| Res::Def(DefKind::TyParam, _)
- | Res::Def(DefKind::AssociatedTy, _) => true,
+ | Res::Def(DefKind::AssocTy, _) => true,
_ => false,
};
let did = register_res(&*cx, path.res);