diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 05d20013859..3fcf972a5b8 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -168,18 +168,17 @@ pub(super) fn root_path(&self) -> String {
}
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("::")
- };
+ let mut title = String::new();
if pushname {
- if !title.is_empty() {
- title.push_str("::");
- }
title.push_str(&it.name.unwrap().as_str());
}
+ if !it.is_primitive() && !it.is_keyword() {
+ if pushname {
+ 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));
diff --git a/src/test/rustdoc/crate-title.rs b/src/test/rustdoc/crate-title.rs
new file mode 100644
index 00000000000..6f96f98e707
--- /dev/null
+++ b/src/test/rustdoc/crate-title.rs
@@ -0,0 +1,3 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//head/title' 'foo - Rust'
diff --git a/src/test/rustdoc/item-title.rs b/src/test/rustdoc/item-title.rs
new file mode 100644
index 00000000000..d0fbdf95ddc
--- /dev/null
+++ b/src/test/rustdoc/item-title.rs
@@ -0,0 +1,33 @@
+#![crate_name = "foo"]
+#![feature(doc_keyword)]
+
+// @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust'
+/// blah
+pub fn widget_count() {}
+
+// @has foo/struct.Widget.html '//head/title' 'Widget in foo - Rust'
+pub struct Widget;
+
+// @has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust'
+pub const ANSWER: u8 = 42;
+
+pub mod blah {
+ // @has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust'
+ pub struct Widget;
+
+ // @has foo/blah/trait.Awesome.html '//head/title' 'Awesome in foo::blah - Rust'
+ pub trait Awesome {}
+
+ // @has foo/blah/fn.make_widget.html '//head/title' 'make_widget in foo::blah - Rust'
+ pub fn make_widget() {}
+
+ // @has foo/macro.cool_macro.html '//head/title' 'cool_macro in foo - Rust'
+ #[macro_export]
+ macro_rules! cool_macro {
+ ($t:tt) => { $t }
+ }
+}
+
+// @has foo/keyword.continue.html '//head/title' 'continue - Rust'
+#[doc(keyword = "continue")]
+mod continue_keyword {}
diff --git a/src/test/rustdoc/mod-title.rs b/src/test/rustdoc/mod-title.rs
new file mode 100644
index 00000000000..6b7f67d17ab
--- /dev/null
+++ b/src/test/rustdoc/mod-title.rs
@@ -0,0 +1,12 @@
+#![crate_name = "foo"]
+
+// @has foo/bar/index.html '//head/title' 'foo::bar - Rust'
+/// blah
+pub mod bar {
+ pub fn a() {}
+}
+
+// @has foo/baz/index.html '//head/title' 'foo::baz - Rust'
+pub mod baz {
+ pub fn a() {}
+}