@@ -51,25 +51,19 @@ 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:: { TyParamBounds , WhereClause , href, AbiSpace } ;
6763use html:: format:: { VisSpace , Method , UnsafetySpace , MutableSpace } ;
68- use html:: highlight;
6964use html:: item_type:: ItemType ;
70- use html:: layout;
71- use html:: markdown:: Markdown ;
72- use html:: markdown;
65+ use html:: markdown:: { self , Markdown } ;
66+ use html:: { highlight, layout} ;
7367
7468/// A pair of name and its optional document.
7569pub type NameDoc = ( String , Option < String > ) ;
@@ -2281,6 +2275,9 @@ fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
22812275 }
22822276}
22832277
2278+ // Render_header is false when we are rendering a `Deref` impl and true
2279+ // otherwise. If render_header is false, we will avoid rendering static
2280+ // methods, since they are not accessible for the type implementing `Deref`
22842281fn render_impl ( w : & mut fmt:: Formatter , i : & Impl , link : MethodLink ,
22852282 render_header : bool ) -> fmt:: Result {
22862283 if render_header {
@@ -2300,14 +2297,17 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: MethodLink,
23002297 }
23012298
23022299 fn doctraititem ( w : & mut fmt:: Formatter , item : & clean:: Item ,
2303- link : MethodLink ) -> fmt:: Result {
2300+ link : MethodLink , render_static : bool ) -> fmt:: Result {
23042301 match item. inner {
23052302 clean:: MethodItem ( ..) | clean:: TyMethodItem ( ..) => {
2306- try!( write ! ( w, "<h4 id='method.{}' class='{}'><code>" ,
2307- * item. name. as_ref( ) . unwrap( ) ,
2308- shortty( item) ) ) ;
2309- try!( render_method ( w, item, link) ) ;
2310- try!( write ! ( w, "</code></h4>\n " ) ) ;
2303+ // Only render when the method is not static or we allow static methods
2304+ if !is_static_method ( item) || render_static {
2305+ try!( write ! ( w, "<h4 id='method.{}' class='{}'><code>" ,
2306+ * item. name. as_ref( ) . unwrap( ) ,
2307+ shortty( item) ) ) ;
2308+ try!( render_method ( w, item, link) ) ;
2309+ try!( write ! ( w, "</code></h4>\n " ) ) ;
2310+ }
23112311 }
23122312 clean:: TypedefItem ( ref tydef) => {
23132313 let name = item. name . as_ref ( ) . unwrap ( ) ;
@@ -2327,30 +2327,44 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: MethodLink,
23272327 }
23282328 _ => panic ! ( "can't make docs for trait item with name {:?}" , item. name)
23292329 }
2330- if let MethodLink :: Anchor = link {
2331- document ( w, item)
2330+
2331+ return if let MethodLink :: Anchor = link {
2332+ if is_static_method ( item) && !render_static {
2333+ Ok ( ( ) )
2334+ } else {
2335+ document ( w, item)
2336+ }
23322337 } else {
23332338 Ok ( ( ) )
2339+ } ;
2340+
2341+ fn is_static_method ( item : & clean:: Item ) -> bool {
2342+ match item. inner {
2343+ clean:: MethodItem ( ref method) => method. self_ == SelfTy :: SelfStatic ,
2344+ clean:: TyMethodItem ( ref method) => method. self_ == SelfTy :: SelfStatic ,
2345+ _ => false
2346+ }
23342347 }
23352348 }
23362349
23372350 try!( write ! ( w, "<div class='impl-items'>" ) ) ;
23382351 for trait_item in i. impl_ . items . iter ( ) {
2339- try!( doctraititem ( w, trait_item, link) ) ;
2352+ try!( doctraititem ( w, trait_item, link, render_header ) ) ;
23402353 }
23412354
23422355 fn render_default_methods ( w : & mut fmt:: Formatter ,
23432356 did : ast:: DefId ,
23442357 t : & clean:: Trait ,
2345- i : & clean:: Impl ) -> fmt:: Result {
2358+ i : & clean:: Impl ,
2359+ render_static : bool ) -> fmt:: Result {
23462360 for trait_item in & t. items {
23472361 let n = trait_item. name . clone ( ) ;
23482362 match i. items . iter ( ) . find ( |m| { m. name == n } ) {
23492363 Some ( ..) => continue ,
23502364 None => { }
23512365 }
23522366
2353- try!( doctraititem ( w, trait_item, MethodLink :: GotoSource ( did) ) ) ;
2367+ try!( doctraititem ( w, trait_item, MethodLink :: GotoSource ( did) , render_static ) ) ;
23542368 }
23552369 Ok ( ( ) )
23562370 }
@@ -2361,7 +2375,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: MethodLink,
23612375 // for them work.
23622376 if let Some ( clean:: ResolvedPath { did, .. } ) = i. impl_ . trait_ {
23632377 if let Some ( t) = cache ( ) . traits . get ( & did) {
2364- try!( render_default_methods ( w, did, t, & i. impl_ ) ) ;
2378+ try!( render_default_methods ( w, did, t, & i. impl_ , render_header ) ) ;
23652379 }
23662380 }
23672381 try!( write ! ( w, "</div>" ) ) ;
0 commit comments