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.
This commit is contained in:
mitaa 2016-02-12 09:43:33 +01:00
parent a085e3bd45
commit 938202c81f
4 changed files with 9 additions and 9 deletions

View File

@ -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, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(write!(w, "type {} = {}", name, tydef.type_));
try!(write!(w, "</code></h4>\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, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_const(w, item, ty, default.as_ref()));
try!(write!(w, "</code></h4>\n"));
}
clean::ConstantItem(ref c) => {
let id = derive_id(format!("assoc_const.{}", name));
let id = derive_id(format!("associatedconstant.{}", name));
try!(write!(w, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_const(w, item, &c.type_, Some(&c.expr)));
try!(write!(w, "</code></h4>\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, "<h4 id='{}' class='{}'><code>", id, shortty(item)));
try!(assoc_type(w, item, bounds, default));
try!(write!(w, "</code></h4>\n"));

View File

@ -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;
}

View File

@ -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};

View File

@ -31,21 +31,21 @@ impl<T> Foo<T> {
}
impl<T> Bar for Foo<T> {
// @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<T> {
// @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<T> {
// @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)'