@@ -1343,12 +1343,12 @@ impl Context {
1343
1343
} else {
1344
1344
let mut url = repeat ( "../" ) . take ( cx. current . len ( ) )
1345
1345
. collect :: < String > ( ) ;
1346
- if let Some ( & ( ref names, _ ) ) = cache ( ) . paths . get ( & it. def_id ) {
1346
+ if let Some ( & ( ref names, ty ) ) = cache ( ) . paths . get ( & it. def_id ) {
1347
1347
for name in & names[ ..names. len ( ) - 1 ] {
1348
1348
url. push_str ( name) ;
1349
1349
url. push_str ( "/" ) ;
1350
1350
}
1351
- url. push_str ( & item_path ( it ) ) ;
1351
+ url. push_str ( & item_path ( ty , names . last ( ) . unwrap ( ) ) ) ;
1352
1352
layout:: redirect ( writer, & url) ?;
1353
1353
}
1354
1354
}
@@ -1409,7 +1409,8 @@ impl Context {
1409
1409
render ( & mut buf, self , & item, true ) . unwrap ( ) ;
1410
1410
// buf will be empty if the item is stripped and there is no redirect for it
1411
1411
if !buf. is_empty ( ) {
1412
- let joint_dst = self . dst . join ( & item_path ( & item) ) ;
1412
+ let joint_dst = self . dst . join ( & item_path ( shortty ( & item) ,
1413
+ item. name . as_ref ( ) . unwrap ( ) ) ) ;
1413
1414
try_err ! ( fs:: create_dir_all( & self . dst) , & self . dst) ;
1414
1415
let mut dst = try_err ! ( File :: create( & joint_dst) , & joint_dst) ;
1415
1416
try_err ! ( dst. write_all( & buf) , & joint_dst) ;
@@ -1531,7 +1532,7 @@ impl<'a> Item<'a> {
1531
1532
Some ( format ! ( "{root}{path}/{file}?gotosrc={goto}" ,
1532
1533
root = root,
1533
1534
path = path[ ..path. len( ) - 1 ] . join( "/" ) ,
1534
- file = item_path( self . item) ,
1535
+ file = item_path( shortty ( self . item) , self . item . name . as_ref ( ) . unwrap ( ) ) ,
1535
1536
goto = self . item. def_id. index. as_usize( ) ) )
1536
1537
}
1537
1538
}
@@ -1623,13 +1624,10 @@ impl<'a> fmt::Display for Item<'a> {
1623
1624
}
1624
1625
}
1625
1626
1626
- fn item_path ( item : & clean:: Item ) -> String {
1627
- if item. is_mod ( ) {
1628
- format ! ( "{}/index.html" , item. name. as_ref( ) . unwrap( ) )
1629
- } else {
1630
- format ! ( "{}.{}.html" ,
1631
- shortty( item) . to_static_str( ) ,
1632
- * item. name. as_ref( ) . unwrap( ) )
1627
+ fn item_path ( ty : ItemType , name : & str ) -> String {
1628
+ match ty {
1629
+ ItemType :: Module => format ! ( "{}/index.html" , name) ,
1630
+ _ => format ! ( "{}.{}.html" , ty. to_static_str( ) , name) ,
1633
1631
}
1634
1632
}
1635
1633
@@ -1821,7 +1819,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
1821
1819
docs = shorter( Some ( & Markdown ( doc_value) . to_string( ) ) ) ,
1822
1820
class = shortty( myitem) ,
1823
1821
stab = myitem. stability_class( ) ,
1824
- href = item_path( myitem) ,
1822
+ href = item_path( shortty ( myitem) , myitem . name . as_ref ( ) . unwrap ( ) ) ,
1825
1823
title = full_path( cx, myitem) ) ?;
1826
1824
}
1827
1825
}
0 commit comments