@@ -1816,7 +1816,7 @@ fn render_impl(
18161816 let item_type = item. type_ ( ) ;
18171817 let name = item. name . as_ref ( ) . unwrap ( ) ;
18181818
1819- let render_method_item = rendering_params. show_non_assoc_items
1819+ let render_assoc_fn = rendering_params. show_non_assoc_items
18201820 && match render_mode {
18211821 RenderMode :: Normal => true ,
18221822 RenderMode :: ForDeref { mut_ : deref_mut_, is_deref_target_copy } => {
@@ -1836,7 +1836,7 @@ fn render_impl(
18361836 let mut short_documented = true ;
18371837
18381838 let mut trait_item_deprecated = false ;
1839- if render_method_item {
1839+ if render_assoc_fn {
18401840 if !is_default_item {
18411841 if let Some ( t) = trait_ {
18421842 // The trait item may have been stripped so we might not
@@ -1899,99 +1899,96 @@ fn render_impl(
18991899 deprecation_class = "" ;
19001900 }
19011901 match & item. kind {
1902- ItemKind :: AssocFn ( ..) => {
1903- // Only render when the method is not static or we allow static methods
1904- if render_method_item {
1905- let id = cx. derive_id ( format ! ( "{item_type}.{name}" ) ) ;
1906- let source_id = trait_
1907- . and_then ( |trait_| {
1908- trait_
1909- . items
1910- . iter ( )
1911- . find ( |item| item. name . map ( |n| n == * name) . unwrap_or ( false ) )
1912- } )
1913- . map ( |item| format ! ( "{}.{name}" , item. type_( ) ) ) ;
1914- write ! (
1915- w,
1916- "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
1917- {}",
1918- render_rightside( cx, item, render_mode)
1919- ) ?;
1920- if trait_. is_some ( ) {
1921- // Anchors are only used on trait impls.
1922- write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
1923- }
1924- write ! (
1925- w,
1926- "<h4 class=\" code-header\" >{}</h4></section>" ,
1927- render_assoc_item(
1928- item,
1929- link. anchor( source_id. as_ref( ) . unwrap_or( & id) ) ,
1930- ItemType :: Impl ,
1931- 0 ,
1932- Ending :: Newline ,
1933- render_mode,
1934- cx,
1935- ) ,
1936- ) ?;
1902+ ItemKind :: AssocFn ( _) if !render_assoc_fn => { }
1903+ ItemKind :: AssocConst ( _) | ItemKind :: AssocTy ( _)
1904+ if let RenderMode :: ForDeref { .. } = render_mode => { }
1905+
1906+ ItemKind :: AssocFn ( _) => {
1907+ let id = cx. derive_id ( format ! ( "{item_type}.{name}" ) ) ;
1908+ let source_id = trait_
1909+ . and_then ( |trait_| {
1910+ trait_
1911+ . items
1912+ . iter ( )
1913+ . find ( |item| item. name . map ( |n| n == * name) . unwrap_or ( false ) )
1914+ } )
1915+ . map ( |item| format ! ( "{}.{name}" , item. type_( ) ) ) ;
1916+ write ! (
1917+ w,
1918+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
1919+ {}",
1920+ render_rightside( cx, item, render_mode)
1921+ ) ?;
1922+ if trait_. is_some ( ) {
1923+ // Anchors are only used on trait impls.
1924+ write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
19371925 }
1926+ write ! (
1927+ w,
1928+ "<h4 class=\" code-header\" >{}</h4></section>" ,
1929+ render_assoc_item(
1930+ item,
1931+ link. anchor( source_id. as_ref( ) . unwrap_or( & id) ) ,
1932+ ItemType :: Impl ,
1933+ 0 ,
1934+ Ending :: Newline ,
1935+ render_mode,
1936+ cx,
1937+ ) ,
1938+ ) ?;
19381939 }
19391940 ItemKind :: AssocConst ( ct) => {
1940- if !matches ! ( render_mode, RenderMode :: ForDeref { .. } ) {
1941- let source_id = format ! ( "{item_type}.{name}" ) ;
1942- let id = cx. derive_id ( & source_id) ;
1943- write ! (
1944- w,
1945- "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
1946- {}",
1947- render_rightside( cx, item, render_mode) ,
1948- ) ?;
1949- if trait_. is_some ( ) {
1950- // Anchors are only used on trait impls.
1951- write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
1952- }
1953- write ! (
1954- w,
1955- "<h4 class=\" code-header\" >{}</h4></section>" ,
1956- assoc_const(
1957- item,
1958- ct,
1959- ItemType :: Impl ,
1960- link. anchor( if trait_. is_some( ) { & source_id } else { & id } ) ,
1961- 0 ,
1962- Ending :: Newline ,
1963- cx,
1964- ) ,
1965- ) ?;
1941+ let source_id = format ! ( "{item_type}.{name}" ) ;
1942+ let id = cx. derive_id ( & source_id) ;
1943+ write ! (
1944+ w,
1945+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
1946+ {}",
1947+ render_rightside( cx, item, render_mode) ,
1948+ ) ?;
1949+ if trait_. is_some ( ) {
1950+ // Anchors are only used on trait impls.
1951+ write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
19661952 }
1953+ write ! (
1954+ w,
1955+ "<h4 class=\" code-header\" >{}</h4></section>" ,
1956+ assoc_const(
1957+ item,
1958+ ct,
1959+ ItemType :: Impl ,
1960+ link. anchor( if trait_. is_some( ) { & source_id } else { & id } ) ,
1961+ 0 ,
1962+ Ending :: Newline ,
1963+ cx,
1964+ ) ,
1965+ ) ?;
19671966 }
19681967 ItemKind :: AssocTy ( ty) => {
1969- if !matches ! ( render_mode, RenderMode :: ForDeref { .. } ) {
1970- let source_id = format ! ( "{item_type}.{name}" ) ;
1971- let id = cx. derive_id ( & source_id) ;
1972- write ! (
1973- w,
1974- "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
1968+ let source_id = format ! ( "{item_type}.{name}" ) ;
1969+ let id = cx. derive_id ( & source_id) ;
1970+ write ! (
1971+ w,
1972+ "<section id=\" {id}\" class=\" {item_type}{in_trait_class}{deprecation_class}\" >\
19751973 {}",
1976- render_rightside( cx, item, render_mode) ,
1977- ) ?;
1978- if trait_. is_some ( ) {
1979- // Anchors are only used on trait impls.
1980- write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
1981- }
1982- write ! (
1983- w,
1984- "<h4 class=\" code-header\" >{}</h4></section>" ,
1985- assoc_ty(
1986- item,
1987- ty,
1988- link. anchor( if trait_. is_some( ) { & source_id } else { & id } ) ,
1989- 0 ,
1990- Ending :: Newline ,
1991- cx,
1992- ) ,
1993- ) ?;
1974+ render_rightside( cx, item, render_mode) ,
1975+ ) ?;
1976+ if trait_. is_some ( ) {
1977+ // Anchors are only used on trait impls.
1978+ write ! ( w, "<a href=\" #{id}\" class=\" anchor\" >§</a>" ) ?;
19941979 }
1980+ write ! (
1981+ w,
1982+ "<h4 class=\" code-header\" >{}</h4></section>" ,
1983+ assoc_ty(
1984+ item,
1985+ ty,
1986+ link. anchor( if trait_. is_some( ) { & source_id } else { & id } ) ,
1987+ 0 ,
1988+ Ending :: Newline ,
1989+ cx,
1990+ ) ,
1991+ ) ?;
19951992 }
19961993 ItemKind :: Stripped ( ..) => return Ok ( ( ) ) ,
19971994 _ => panic ! ( "can't make docs for trait item with name {:?}" , item. name) ,
0 commit comments