@@ -628,6 +628,7 @@ impl Attributes {
628
628
/// Cache must be populated before call
629
629
pub fn links ( & self , krate : & CrateNum ) -> Vec < ( String , String ) > {
630
630
use crate :: html:: format:: href;
631
+ use crate :: html:: render:: CURRENT_DEPTH ;
631
632
632
633
self . links
633
634
. iter ( )
@@ -648,12 +649,13 @@ impl Attributes {
648
649
if let Some ( ref fragment) = * fragment {
649
650
let cache = cache ( ) ;
650
651
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)
653
655
}
654
- Some ( & ( _, _, ExternalLocation :: Remote ( ref s) ) ) => s,
656
+ Some ( & ( _, _, ExternalLocation :: Remote ( ref s) ) ) => s. to_string ( ) ,
655
657
Some ( & ( _, _, ExternalLocation :: Unknown ) ) | None => {
656
- "https://doc.rust-lang.org/nightly"
658
+ String :: from ( "https://doc.rust-lang.org/nightly" )
657
659
}
658
660
} ;
659
661
// This is a primitive so the url is done "by hand".
0 commit comments