@@ -508,6 +508,18 @@ impl Item {
508508 . as_ref ( )
509509 . or_else ( || self . stability . as_ref ( ) . and_then ( |s| s. deprecation . as_ref ( ) ) )
510510 }
511+ pub fn is_default ( & self ) -> bool {
512+ match self . inner {
513+ ItemEnum :: MethodItem ( ref meth) => {
514+ if let Some ( defaultness) = meth. defaultness {
515+ defaultness. has_value ( ) && !defaultness. is_final ( )
516+ } else {
517+ false
518+ }
519+ }
520+ _ => false ,
521+ }
522+ }
511523}
512524
513525#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1700,9 +1712,11 @@ pub struct Method {
17001712 pub generics : Generics ,
17011713 pub decl : FnDecl ,
17021714 pub header : hir:: FnHeader ,
1715+ pub defaultness : Option < hir:: Defaultness > ,
17031716}
17041717
1705- impl < ' a > Clean < Method > for ( & ' a hir:: MethodSig , & ' a hir:: Generics , hir:: BodyId ) {
1718+ impl < ' a > Clean < Method > for ( & ' a hir:: MethodSig , & ' a hir:: Generics , hir:: BodyId ,
1719+ Option < hir:: Defaultness > ) {
17061720 fn clean ( & self , cx : & DocContext < ' _ > ) -> Method {
17071721 let ( generics, decl) = enter_impl_trait ( cx, || {
17081722 ( self . 1 . clean ( cx) , ( & * self . 0 . decl , self . 2 ) . clean ( cx) )
@@ -1711,6 +1725,7 @@ impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId)
17111725 decl,
17121726 generics,
17131727 header : self . 0 . header ,
1728+ defaultness : self . 3 ,
17141729 }
17151730 }
17161731}
@@ -2016,7 +2031,7 @@ impl Clean<Item> for hir::TraitItem {
20162031 default. map ( |e| print_const_expr ( cx, e) ) )
20172032 }
20182033 hir:: TraitItemKind :: Method ( ref sig, hir:: TraitMethod :: Provided ( body) ) => {
2019- MethodItem ( ( sig, & self . generics , body) . clean ( cx) )
2034+ MethodItem ( ( sig, & self . generics , body, None ) . clean ( cx) )
20202035 }
20212036 hir:: TraitItemKind :: Method ( ref sig, hir:: TraitMethod :: Required ( ref names) ) => {
20222037 let ( generics, decl) = enter_impl_trait ( cx, || {
@@ -2054,7 +2069,7 @@ impl Clean<Item> for hir::ImplItem {
20542069 Some ( print_const_expr ( cx, expr) ) )
20552070 }
20562071 hir:: ImplItemKind :: Method ( ref sig, body) => {
2057- MethodItem ( ( sig, & self . generics , body) . clean ( cx) )
2072+ MethodItem ( ( sig, & self . generics , body, Some ( self . defaultness ) ) . clean ( cx) )
20582073 }
20592074 hir:: ImplItemKind :: Type ( ref ty) => TypedefItem ( Typedef {
20602075 type_ : ty. clean ( cx) ,
@@ -2137,7 +2152,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
21372152 abi : sig. abi ( ) ,
21382153 constness,
21392154 asyncness : hir:: IsAsync :: NotAsync ,
2140- }
2155+ } ,
2156+ defaultness : Some ( self . defaultness ) ,
21412157 } )
21422158 } else {
21432159 TyMethodItem ( TyMethod {
0 commit comments