From 938202c81f309d78925516e13f119a5f1112a62b Mon Sep 17 00:00:00 2001 From: mitaa Date: Fri, 12 Feb 2016 09:43:33 +0100 Subject: [PATCH] Fix associated item identifiers Search results use the mapping found in `ItemType::to_static_str` for the identifier, which could not be found on the page in the case of associated items. --- src/librustdoc/html/render.rs | 8 ++++---- src/test/rustdoc/assoc-consts.rs | 2 +- src/test/rustdoc/issue-21092.rs | 2 +- src/test/rustdoc/issue-25001.rs | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 12a17afcc7c..b97ccfd3c88 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2550,25 +2550,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi } } clean::TypedefItem(ref tydef, _) => { - let id = derive_id(format!("assoc_type.{}", name)); + let id = derive_id(format!("associatedtype.{}", name)); try!(write!(w, "

", id, shortty(item))); try!(write!(w, "type {} = {}", name, tydef.type_)); try!(write!(w, "

\n")); } clean::AssociatedConstItem(ref ty, ref default) => { - let id = derive_id(format!("assoc_const.{}", name)); + let id = derive_id(format!("associatedconstant.{}", name)); try!(write!(w, "

", id, shortty(item))); try!(assoc_const(w, item, ty, default.as_ref())); try!(write!(w, "

\n")); } clean::ConstantItem(ref c) => { - let id = derive_id(format!("assoc_const.{}", name)); + let id = derive_id(format!("associatedconstant.{}", name)); try!(write!(w, "

", id, shortty(item))); try!(assoc_const(w, item, &c.type_, Some(&c.expr))); try!(write!(w, "

\n")); } clean::AssociatedTypeItem(ref bounds, ref default) => { - let id = derive_id(format!("assoc_type.{}", name)); + let id = derive_id(format!("associatedtype.{}", name)); try!(write!(w, "

", id, shortty(item))); try!(assoc_type(w, item, bounds, default)); try!(write!(w, "

\n")); diff --git a/src/test/rustdoc/assoc-consts.rs b/src/test/rustdoc/assoc-consts.rs index 20d4c744414..8d3f9b59bb2 100644 --- a/src/test/rustdoc/assoc-consts.rs +++ b/src/test/rustdoc/assoc-consts.rs @@ -20,7 +20,7 @@ pub trait Foo { pub struct Bar; impl Bar { - // @has assoc_consts/struct.Bar.html '//*[@id="assoc_const.BAR"]' \ + // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ // 'const BAR: usize = 3' pub const BAR: usize = 3; } diff --git a/src/test/rustdoc/issue-21092.rs b/src/test/rustdoc/issue-21092.rs index 745c6e2c664..ff48c70fc58 100644 --- a/src/test/rustdoc/issue-21092.rs +++ b/src/test/rustdoc/issue-21092.rs @@ -14,5 +14,5 @@ extern crate issue_21092; // @has issue_21092/struct.Bar.html -// @has - '//*[@id="assoc_type.Bar"]' 'type Bar = i32' +// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' pub use issue_21092::{Foo, Bar}; diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs index e4d97828d50..2343b610ce4 100644 --- a/src/test/rustdoc/issue-25001.rs +++ b/src/test/rustdoc/issue-25001.rs @@ -31,21 +31,21 @@ impl Foo { } impl Bar for Foo { - // @has - '//*[@id="assoc_type.Item"]//code' 'type Item = T' + // @has - '//*[@id="associatedtype.Item"]//code' 'type Item = T' type Item=T; // @has - '//*[@id="method.quux"]//code' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a Foo { - // @has - '//*[@id="assoc_type.Item-1"]//code' "type Item = &'a T" + // @has - '//*[@id="associatedtype.Item-1"]//code' "type Item = &'a T" type Item=&'a T; // @has - '//*[@id="method.quux-1"]//code' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a mut Foo { - // @has - '//*[@id="assoc_type.Item-2"]//code' "type Item = &'a mut T" + // @has - '//*[@id="associatedtype.Item-2"]//code' "type Item = &'a mut T" type Item=&'a mut T; // @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)'