@@ -8,7 +8,7 @@ use crate::html::layout;
88use crate :: html:: render:: { SharedContext , BASIC_KEYWORDS } ;
99use rustc_hir:: def_id:: LOCAL_CRATE ;
1010use rustc_span:: source_map:: FileName ;
11- use std:: ffi:: OsStr ;
11+ use std:: ffi:: { OsStr , OsString } ;
1212use std:: fs;
1313use std:: path:: { Component , Path , PathBuf } ;
1414
@@ -84,7 +84,7 @@ impl<'a> SourceCollector<'a> {
8484 } ;
8585
8686 // Remove the utf-8 BOM if any
87- if contents. starts_with ( " \u{feff} " ) {
87+ if contents. starts_with ( ' \u{feff}' ) {
8888 contents. drain ( ..3 ) ;
8989 }
9090
@@ -99,16 +99,15 @@ impl<'a> SourceCollector<'a> {
9999 href. push ( '/' ) ;
100100 } ) ;
101101 self . scx . ensure_dir ( & cur) ?;
102- let mut fname = p. file_name ( ) . expect ( "source has no filename" ) . to_os_string ( ) ;
103- fname. push ( ".html" ) ;
102+
103+ let src_fname =
104+ String :: from ( p. file_name ( ) . expect ( "source has no filename" ) . to_string_lossy ( ) ) ;
105+ let fname = OsString :: from ( src_fname. clone ( ) + ".html" ) ;
104106 cur. push ( & fname) ;
105107 href. push_str ( & fname. to_string_lossy ( ) ) ;
106108
107- let title = format ! (
108- "{} -- source" ,
109- cur. file_name( ) . expect( "failed to get file name" ) . to_string_lossy( )
110- ) ;
111- let desc = format ! ( "Source to the Rust file `{}`." , filename) ;
109+ let title = format ! ( "{} – source" , src_fname, ) ;
110+ let desc = format ! ( "Source of the Rust file `{}`." , filename) ;
112111 let page = layout:: Page {
113112 title : & title,
114113 css_class : "source" ,
0 commit comments