@@ -628,6 +628,7 @@ impl Attributes {
628628 /// Cache must be populated before call
629629 pub fn links ( & self , krate : & CrateNum ) -> Vec < ( String , String ) > {
630630 use crate :: html:: format:: href;
631+ use crate :: html:: render:: CURRENT_DEPTH ;
631632
632633 self . links
633634 . iter ( )
@@ -648,12 +649,13 @@ impl Attributes {
648649 if let Some ( ref fragment) = * fragment {
649650 let cache = cache ( ) ;
650651 let url = match cache. extern_locations . get ( krate) {
651- Some ( & ( _, ref src, ExternalLocation :: Local ) ) => {
652- src. to_str ( ) . expect ( "invalid file path" )
652+ Some ( & ( _, _, ExternalLocation :: Local ) ) => {
653+ let depth = CURRENT_DEPTH . with ( |l| l. get ( ) ) ;
654+ "../" . repeat ( depth)
653655 }
654- Some ( & ( _, _, ExternalLocation :: Remote ( ref s) ) ) => s,
656+ Some ( & ( _, _, ExternalLocation :: Remote ( ref s) ) ) => s. to_string ( ) ,
655657 Some ( & ( _, _, ExternalLocation :: Unknown ) ) | None => {
656- "https://doc.rust-lang.org/nightly"
658+ String :: from ( "https://doc.rust-lang.org/nightly" )
657659 }
658660 } ;
659661 // This is a primitive so the url is done "by hand".
0 commit comments