@@ -51,26 +51,20 @@ use std::sync::Arc;
5151
5252use externalfiles:: ExternalHtml ;
5353
54- use serialize:: json;
55- use serialize:: json:: ToJson ;
56- use syntax:: abi;
57- use syntax:: ast;
58- use syntax:: ast_util;
59- use syntax:: attr;
54+ use serialize:: json:: { self , ToJson } ;
55+ use syntax:: { abi, ast, ast_util, attr} ;
6056use rustc:: util:: nodemap:: NodeSet ;
6157
62- use clean;
58+ use clean:: { self , SelfTy } ;
6359use doctree;
6460use fold:: DocFolder ;
6561use html:: escape:: Escape ;
6662use html:: format:: { ConstnessSpace } ;
6763use html:: format:: { TyParamBounds , WhereClause , href, AbiSpace } ;
6864use html:: format:: { VisSpace , Method , UnsafetySpace , MutableSpace } ;
69- use html:: highlight;
7065use html:: item_type:: ItemType ;
71- use html:: layout;
72- use html:: markdown:: Markdown ;
73- use html:: markdown;
66+ use html:: markdown:: { self , Markdown } ;
67+ use html:: { highlight, layout} ;
7468
7569/// A pair of name and its optional document.
7670pub type NameDoc = ( String , Option < String > ) ;
@@ -2329,6 +2323,9 @@ fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
23292323 }
23302324}
23312325
2326+ // Render_header is false when we are rendering a `Deref` impl and true
2327+ // otherwise. If render_header is false, we will avoid rendering static
2328+ // methods, since they are not accessible for the type implementing `Deref`
23322329fn render_impl ( w : & mut fmt:: Formatter , i : & Impl , link : AssocItemLink ,
23332330 render_header : bool ) -> fmt:: Result {
23342331 if render_header {
@@ -2348,14 +2345,17 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
23482345 }
23492346
23502347 fn doctraititem ( w : & mut fmt:: Formatter , item : & clean:: Item ,
2351- link : AssocItemLink ) -> fmt:: Result {
2348+ link : AssocItemLink , render_static : bool ) -> fmt:: Result {
23522349 match item. inner {
23532350 clean:: MethodItem ( ..) | clean:: TyMethodItem ( ..) => {
2354- try!( write ! ( w, "<h4 id='method.{}' class='{}'><code>" ,
2355- * item. name. as_ref( ) . unwrap( ) ,
2356- shortty( item) ) ) ;
2351+ // Only render when the method is not static or we allow static methods
2352+ if !is_static_method ( item) || render_static {
2353+ try!( write ! ( w, "<h4 id='method.{}' class='{}'><code>" ,
2354+ * item. name. as_ref( ) . unwrap( ) ,
2355+ shortty( item) ) ) ;
23572356 try!( render_assoc_item ( w, item, link) ) ;
2358- try!( write ! ( w, "</code></h4>\n " ) ) ;
2357+ try!( write ! ( w, "</code></h4>\n " ) ) ;
2358+ }
23592359 }
23602360 clean:: TypedefItem ( ref tydef) => {
23612361 let name = item. name . as_ref ( ) . unwrap ( ) ;
@@ -2389,30 +2389,44 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
23892389 }
23902390 _ => panic ! ( "can't make docs for trait item with name {:?}" , item. name)
23912391 }
2392- if let AssocItemLink :: Anchor = link {
2393- document ( w, item)
2392+
2393+ return if let AssocItemLink :: Anchor = link {
2394+ if is_static_method ( item) && !render_static {
2395+ Ok ( ( ) )
2396+ } else {
2397+ document ( w, item)
2398+ }
23942399 } else {
23952400 Ok ( ( ) )
2401+ } ;
2402+
2403+ fn is_static_method ( item : & clean:: Item ) -> bool {
2404+ match item. inner {
2405+ clean:: MethodItem ( ref method) => method. self_ == SelfTy :: SelfStatic ,
2406+ clean:: TyMethodItem ( ref method) => method. self_ == SelfTy :: SelfStatic ,
2407+ _ => false
2408+ }
23962409 }
23972410 }
23982411
23992412 try!( write ! ( w, "<div class='impl-items'>" ) ) ;
24002413 for trait_item in i. impl_ . items . iter ( ) {
2401- try!( doctraititem ( w, trait_item, link) ) ;
2414+ try!( doctraititem ( w, trait_item, link, render_header ) ) ;
24022415 }
24032416
24042417 fn render_default_items ( w : & mut fmt:: Formatter ,
24052418 did : ast:: DefId ,
24062419 t : & clean:: Trait ,
2407- i : & clean:: Impl ) -> fmt:: Result {
2420+ i : & clean:: Impl ,
2421+ render_static : bool ) -> fmt:: Result {
24082422 for trait_item in & t. items {
24092423 let n = trait_item. name . clone ( ) ;
24102424 match i. items . iter ( ) . find ( |m| { m. name == n } ) {
24112425 Some ( ..) => continue ,
24122426 None => { }
24132427 }
24142428
2415- try!( doctraititem ( w, trait_item, AssocItemLink :: GotoSource ( did) ) ) ;
2429+ try!( doctraititem ( w, trait_item, AssocItemLink :: GotoSource ( did) , render_static ) ) ;
24162430 }
24172431 Ok ( ( ) )
24182432 }
@@ -2423,7 +2437,8 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
24232437 // for them work.
24242438 if let Some ( clean:: ResolvedPath { did, .. } ) = i. impl_ . trait_ {
24252439 if let Some ( t) = cache ( ) . traits . get ( & did) {
2426- try!( render_default_items ( w, did, t, & i. impl_ ) ) ;
2440+ try!( render_default_items ( w, did, t, & i. impl_ , render_header) ) ;
2441+
24272442 }
24282443 }
24292444 try!( write ! ( w, "</div>" ) ) ;
0 commit comments