parent
43b8503568
commit
abae840f45
6 changed files with 70 additions and 7 deletions
|
@ -306,13 +306,14 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
|
||||||
let mut item = method.clean(cx);
|
let mut item = method.clean(cx);
|
||||||
item.inner = match item.inner.clone() {
|
item.inner = match item.inner.clone() {
|
||||||
clean::TyMethodItem(clean::TyMethod {
|
clean::TyMethodItem(clean::TyMethod {
|
||||||
unsafety, decl, self_, generics
|
unsafety, decl, self_, generics, abi
|
||||||
}) => {
|
}) => {
|
||||||
clean::MethodItem(clean::Method {
|
clean::MethodItem(clean::Method {
|
||||||
unsafety: unsafety,
|
unsafety: unsafety,
|
||||||
decl: decl,
|
decl: decl,
|
||||||
self_: self_,
|
self_: self_,
|
||||||
generics: generics,
|
generics: generics,
|
||||||
|
abi: abi
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => panic!("not a tymethod"),
|
_ => panic!("not a tymethod"),
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub use self::FunctionRetTy::*;
|
||||||
pub use self::TraitMethod::*;
|
pub use self::TraitMethod::*;
|
||||||
|
|
||||||
use syntax;
|
use syntax;
|
||||||
|
use syntax::abi;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::ast_util::PostExpansionMethod;
|
use syntax::ast_util::PostExpansionMethod;
|
||||||
|
@ -945,6 +946,7 @@ pub struct Method {
|
||||||
pub self_: SelfTy,
|
pub self_: SelfTy,
|
||||||
pub unsafety: ast::Unsafety,
|
pub unsafety: ast::Unsafety,
|
||||||
pub decl: FnDecl,
|
pub decl: FnDecl,
|
||||||
|
pub abi: abi::Abi
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for ast::Method {
|
impl Clean<Item> for ast::Method {
|
||||||
|
@ -973,6 +975,7 @@ impl Clean<Item> for ast::Method {
|
||||||
self_: self.pe_explicit_self().node.clean(cx),
|
self_: self.pe_explicit_self().node.clean(cx),
|
||||||
unsafety: self.pe_unsafety().clone(),
|
unsafety: self.pe_unsafety().clone(),
|
||||||
decl: decl,
|
decl: decl,
|
||||||
|
abi: self.pe_abi()
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -984,6 +987,7 @@ pub struct TyMethod {
|
||||||
pub decl: FnDecl,
|
pub decl: FnDecl,
|
||||||
pub generics: Generics,
|
pub generics: Generics,
|
||||||
pub self_: SelfTy,
|
pub self_: SelfTy,
|
||||||
|
pub abi: abi::Abi
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for ast::TypeMethod {
|
impl Clean<Item> for ast::TypeMethod {
|
||||||
|
@ -1011,6 +1015,7 @@ impl Clean<Item> for ast::TypeMethod {
|
||||||
decl: decl,
|
decl: decl,
|
||||||
self_: self.explicit_self.node.clean(cx),
|
self_: self.explicit_self.node.clean(cx),
|
||||||
generics: self.generics.clean(cx),
|
generics: self.generics.clean(cx),
|
||||||
|
abi: self.abi
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1301,6 +1306,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
|
||||||
generics: (&self.generics, subst::FnSpace).clean(cx),
|
generics: (&self.generics, subst::FnSpace).clean(cx),
|
||||||
self_: self_,
|
self_: self_,
|
||||||
decl: (self.def_id, &sig).clean(cx),
|
decl: (self.def_id, &sig).clean(cx),
|
||||||
|
abi: self.fty.abi
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ use externalfiles::ExternalHtml;
|
||||||
|
|
||||||
use serialize::json;
|
use serialize::json;
|
||||||
use serialize::json::ToJson;
|
use serialize::json::ToJson;
|
||||||
|
use syntax::abi;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use rustc::util::nodemap::NodeSet;
|
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 render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
|
||||||
fn method(w: &mut fmt::Formatter, it: &clean::Item, unsafety: ast::Unsafety,
|
fn method(w: &mut fmt::Formatter, it: &clean::Item,
|
||||||
g: &clean::Generics, selfty: &clean::SelfTy,
|
unsafety: ast::Unsafety, abi: abi::Abi,
|
||||||
d: &clean::FnDecl) -> fmt::Result {
|
g: &clean::Generics, selfty: &clean::SelfTy,
|
||||||
write!(w, "{}fn <a href='#{ty}.{name}' class='fnname'>{name}</a>\
|
d: &clean::FnDecl) -> fmt::Result {
|
||||||
|
use syntax::abi::Abi;
|
||||||
|
|
||||||
|
write!(w, "{}{}fn <a href='#{ty}.{name}' class='fnname'>{name}</a>\
|
||||||
{generics}{decl}{where_clause}",
|
{generics}{decl}{where_clause}",
|
||||||
match unsafety {
|
match unsafety {
|
||||||
ast::Unsafety::Unsafe => "unsafe ",
|
ast::Unsafety::Unsafe => "unsafe ",
|
||||||
_ => "",
|
_ => "",
|
||||||
},
|
},
|
||||||
|
match abi {
|
||||||
|
Abi::Rust => String::new(),
|
||||||
|
a => format!("extern {} ", a.to_string())
|
||||||
|
},
|
||||||
ty = shortty(it),
|
ty = shortty(it),
|
||||||
name = it.name.as_ref().unwrap(),
|
name = it.name.as_ref().unwrap(),
|
||||||
generics = *g,
|
generics = *g,
|
||||||
|
@ -1826,10 +1834,10 @@ fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
|
||||||
}
|
}
|
||||||
match meth.inner {
|
match meth.inner {
|
||||||
clean::TyMethodItem(ref m) => {
|
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) => {
|
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) => {
|
clean::AssociatedTypeItem(ref typ) => {
|
||||||
assoc_type(w, meth, typ)
|
assoc_type(w, meth, typ)
|
||||||
|
|
8
src/test/run-make/rustdoc-extern-method/Makefile
Normal file
8
src/test/run-make/rustdoc-extern-method/Makefile
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-include ../tools.mk
|
||||||
|
|
||||||
|
all: foo.rs bar.rs
|
||||||
|
$(HOST_RPATH_ENV) $(RUSTC) foo.rs
|
||||||
|
$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
|
||||||
|
$(HOST_RPATH_ENV) $(RUSTDOC) -L $(TMPDIR) -w html -o $(TMPDIR)/doc bar.rs
|
||||||
|
$(HTMLDOCCK) $(TMPDIR)/doc bar.rs
|
||||||
|
|
24
src/test/run-make/rustdoc-extern-method/bar.rs
Normal file
24
src/test/run-make/rustdoc-extern-method/bar.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
extern crate foo;
|
||||||
|
|
||||||
|
// @has bar/trait.Foo.html //pre "pub trait Foo"
|
||||||
|
// @has - '//*[@id="tymethod.foo"]//code' 'extern "rust-call" fn foo'
|
||||||
|
// @has - '//*[@id="tymethod.foo_"]//code' 'extern "rust-call" fn foo_'
|
||||||
|
pub use foo::Foo;
|
||||||
|
|
||||||
|
// @has bar/trait.Bar.html //pre "pub trait Bar"
|
||||||
|
pub trait Bar {
|
||||||
|
// @has - '//*[@id="tymethod.bar"]//code' 'extern "rust-call" fn bar'
|
||||||
|
extern "rust-call" fn bar(&self, _: ());
|
||||||
|
// @has - '//*[@id="method.bar_"]//code' 'extern "rust-call" fn bar_'
|
||||||
|
extern "rust-call" fn bar_(&self, _: ()) { }
|
||||||
|
}
|
16
src/test/run-make/rustdoc-extern-method/foo.rs
Normal file
16
src/test/run-make/rustdoc-extern-method/foo.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![crate_type="lib"]
|
||||||
|
|
||||||
|
pub trait Foo {
|
||||||
|
extern "rust-call" fn foo(&self, _: ()) -> i32;
|
||||||
|
extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 }
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue