@@ -8,7 +8,7 @@ use crate::html::layout;
8
8
use crate :: html:: render:: { SharedContext , BASIC_KEYWORDS } ;
9
9
use rustc_hir:: def_id:: LOCAL_CRATE ;
10
10
use rustc_span:: source_map:: FileName ;
11
- use std:: ffi:: OsStr ;
11
+ use std:: ffi:: { OsStr , OsString } ;
12
12
use std:: fs;
13
13
use std:: path:: { Component , Path , PathBuf } ;
14
14
@@ -84,7 +84,7 @@ impl<'a> SourceCollector<'a> {
84
84
} ;
85
85
86
86
// Remove the utf-8 BOM if any
87
- if contents. starts_with ( " \u{feff} " ) {
87
+ if contents. starts_with ( ' \u{feff}' ) {
88
88
contents. drain ( ..3 ) ;
89
89
}
90
90
@@ -99,16 +99,15 @@ impl<'a> SourceCollector<'a> {
99
99
href. push ( '/' ) ;
100
100
} ) ;
101
101
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" ) ;
104
106
cur. push ( & fname) ;
105
107
href. push_str ( & fname. to_string_lossy ( ) ) ;
106
108
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) ;
112
111
let page = layout:: Page {
113
112
title : & title,
114
113
css_class : "source" ,
0 commit comments