Skip to content

rustdoc: Fix search-index entry for inherent-associated-const #31596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,10 +1281,8 @@ impl Clean<Item> for hir::ImplItem {
fn clean(&self, cx: &DocContext) -> Item {
let inner = match self.node {
hir::ImplItemKind::Const(ref ty, ref expr) => {
ConstantItem(Constant{
type_: ty.clean(cx),
expr: expr.span.to_src(cx),
})
AssociatedConstItem(ty.clean(cx),
Some(expr.span.to_src(cx)))
}
hir::ImplItemKind::Method(ref sig, _) => {
MethodItem(sig.clean(cx))
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/assoc-consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/test/rustdoc/issue-21092.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
6 changes: 3 additions & 3 deletions src/test/rustdoc/issue-25001.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down