diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 05d2001385929..0aa7aa763c2af 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -167,19 +167,18 @@ impl<'tcx> Context<'tcx> { "../".repeat(self.current.len()) } - fn render_item(&self, it: &clean::Item, pushname: bool) -> String { - let mut title = if it.is_primitive() || it.is_keyword() { - // No need to include the namespace for primitive types and keywords - String::new() - } else { - self.current.join("::") - }; - if pushname { - if !title.is_empty() { - title.push_str("::"); - } + fn render_item(&self, it: &clean::Item, is_module: bool) -> String { + let mut title = String::new(); + if !is_module { title.push_str(&it.name.unwrap().as_str()); } + if !it.is_primitive() && !it.is_keyword() { + if !is_module { + title.push_str(" in "); + } + // No need to include the namespace for primitive types and keywords + title.push_str(&self.current.join("::")); + }; title.push_str(" - Rust"); let tyname = it.type_(); let desc = it.doc_value().as_ref().map(|doc| plain_text_summary(&doc)); @@ -598,7 +597,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { info!("Recursing into {}", self.dst.display()); - let buf = self.render_item(item, false); + let buf = self.render_item(item, true); // buf will be empty if the module is stripped and there is no redirect for it if !buf.is_empty() { self.shared.ensure_dir(&self.dst)?; @@ -641,7 +640,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { self.render_redirect_pages = item.is_stripped(); } - let buf = self.render_item(&item, true); + let buf = self.render_item(&item, false); // buf will be empty if the item is stripped and there is no redirect for it if !buf.is_empty() { let name = item.name.as_ref().unwrap(); diff --git a/src/test/rustdoc/prim-title.rs b/src/test/rustdoc/prim-title.rs deleted file mode 100644 index fa3fd512fada6..0000000000000 --- a/src/test/rustdoc/prim-title.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_name = "foo"] - -// @has foo/primitive.u8.html '//head/title' 'u8 - Rust' -// @!has - '//head/title' 'foo' -#[doc(primitive = "u8")] -/// `u8` docs -mod u8 {} diff --git a/src/test/rustdoc/tab_title.rs b/src/test/rustdoc/tab_title.rs new file mode 100644 index 0000000000000..7dce6092deaed --- /dev/null +++ b/src/test/rustdoc/tab_title.rs @@ -0,0 +1,44 @@ +#![crate_name = "foo"] +#![feature(doc_keyword)] + +// tests for the html