@@ -46,7 +46,7 @@ use std::io::prelude::*;
46
46
use std:: io:: { self , BufWriter , BufReader } ;
47
47
use std:: iter:: repeat;
48
48
use std:: mem;
49
- use std:: path:: { PathBuf , Path } ;
49
+ use std:: path:: { PathBuf , Path , Component } ;
50
50
use std:: str;
51
51
use std:: sync:: Arc ;
52
52
@@ -810,16 +810,17 @@ fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) wh
810
810
// make it relative, if possible
811
811
let p = p. strip_prefix ( src_root) . unwrap_or ( p) ;
812
812
813
- let mut iter = p. iter ( ) . map ( |x| x. to_str ( ) . unwrap ( ) ) . peekable ( ) ;
813
+ let mut iter = p. components ( ) . peekable ( ) ;
814
+
814
815
while let Some ( c) = iter. next ( ) {
815
816
if !keep_filename && iter. peek ( ) . is_none ( ) {
816
817
break ;
817
818
}
818
819
819
- if ".." == c {
820
- f ( "up" ) ;
821
- } else {
822
- f ( c )
820
+ match c {
821
+ Component :: ParentDir => f ( "up" ) ,
822
+ Component :: Normal ( c ) => f ( c . to_str ( ) . unwrap ( ) ) ,
823
+ _ => continue ,
823
824
}
824
825
}
825
826
}
@@ -871,7 +872,7 @@ impl<'a> DocFolder for SourceCollector<'a> {
871
872
// entire crate. The other option is maintaining this mapping on a
872
873
// per-file basis, but that's probably not worth it...
873
874
self . cx
874
- . include_sources = match self . emit_source ( & item. source . filename ) {
875
+ . include_sources = match self . emit_source ( & item. source . filename ) {
875
876
Ok ( ( ) ) => true ,
876
877
Err ( e) => {
877
878
println ! ( "warning: source code was requested to be rendered, \
@@ -1489,9 +1490,11 @@ impl<'a> Item<'a> {
1489
1490
true , |component| {
1490
1491
path. push ( component. to_string ( ) ) ;
1491
1492
} ) ;
1493
+
1492
1494
// If the span points into an external macro the
1493
1495
// source-file will be bogus, i.e `<foo macros>`
1494
- if Path :: new ( & self . item . source . filename ) . is_file ( ) {
1496
+ let filename = & self . item . source . filename ;
1497
+ if !( filename. starts_with ( "<" ) && filename. ends_with ( "macros>" ) ) {
1495
1498
Some ( format ! ( "{root}src/{krate}/{path}.html#{href}" ,
1496
1499
root = self . cx. root_path,
1497
1500
krate = self . cx. layout. krate,
0 commit comments