rustdoc: Show non-Rust ABIs on methods

Fix #21621
This commit is contained in:
Tom Jakubowski
2015-02-06 00:51:38 -08:00
parent 43b8503568
commit abae840f45
6 changed files with 70 additions and 7 deletions

View File

@@ -50,6 +50,7 @@ use externalfiles::ExternalHtml;
use serialize::json;
use serialize::json::ToJson;
use syntax::abi;
use syntax::ast;
use syntax::ast_util;
use rustc::util::nodemap::NodeSet;
@@ -1809,15 +1810,22 @@ fn assoc_type(w: &mut fmt::Formatter, it: &clean::Item,
}
fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
fn method(w: &mut fmt::Formatter, it: &clean::Item, unsafety: ast::Unsafety,
g: &clean::Generics, selfty: &clean::SelfTy,
d: &clean::FnDecl) -> fmt::Result {
write!(w, "{}fn <a href='#{ty}.{name}' class='fnname'>{name}</a>\
fn method(w: &mut fmt::Formatter, it: &clean::Item,
unsafety: ast::Unsafety, abi: abi::Abi,
g: &clean::Generics, selfty: &clean::SelfTy,
d: &clean::FnDecl) -> fmt::Result {
use syntax::abi::Abi;
write!(w, "{}{}fn <a href='#{ty}.{name}' class='fnname'>{name}</a>\
{generics}{decl}{where_clause}",
match unsafety {
ast::Unsafety::Unsafe => "unsafe ",
_ => "",
},
match abi {
Abi::Rust => String::new(),
a => format!("extern {} ", a.to_string())
},
ty = shortty(it),
name = it.name.as_ref().unwrap(),
generics = *g,
@@ -1826,10 +1834,10 @@ fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
}
match meth.inner {
clean::TyMethodItem(ref m) => {
method(w, meth, m.unsafety, &m.generics, &m.self_, &m.decl)
method(w, meth, m.unsafety, m.abi, &m.generics, &m.self_, &m.decl)
}
clean::MethodItem(ref m) => {
method(w, meth, m.unsafety, &m.generics, &m.self_, &m.decl)
method(w, meth, m.unsafety, m.abi, &m.generics, &m.self_, &m.decl)
}
clean::AssociatedTypeItem(ref typ) => {
assoc_type(w, meth, typ)