Skip to content

Commit 72ae00b

Browse files
authored
Rollup merge of #78094 - camelid:rustdoc-fix-source-title, r=jyn514
rustdoc: Show the correct source filename in page titles, without `.html` Previously the title would be lib.rs.html -- source if `lib.rs` was the actual source filename. Now the title is lib.rs - source
2 parents 89c98cd + 243c8e9 commit 72ae00b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/librustdoc/html/sources.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -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();
102+
103+
let src_fname = p.file_name().expect("source has no filename").to_os_string();
104+
let mut fname = src_fname.clone();
103105
fname.push(".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.to_string_lossy());
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

Comments
 (0)