1
Fork 0

rustdoc: Emit purity to function dox for traits

Closes #3804
This commit is contained in:
Alex Crichton 2013-09-23 20:38:17 -07:00
parent eaaf2bd41f
commit acab4a8c8e
5 changed files with 21 additions and 13 deletions

View file

@ -18,6 +18,7 @@ use clean;
use html::render::{cache_key, current_location_key};
pub struct VisSpace(Option<ast::visibility>);
pub struct PuritySpace(ast::purity);
pub struct Method<'self>(&'self clean::SelfTy, &'self clean::FnDecl);
impl fmt::Default for clean::Generics {
@ -228,11 +229,7 @@ impl fmt::Default for clean::Type {
None => {}
}
write!(f.buf, "{}{}fn{}",
match decl.purity {
ast::unsafe_fn => "unsafe ",
ast::extern_fn => "extern ",
ast::impure_fn => ""
},
PuritySpace(decl.purity),
match decl.onceness {
ast::Once => "once ",
ast::Many => "",
@ -242,11 +239,7 @@ impl fmt::Default for clean::Type {
}
clean::BareFunction(ref decl) => {
write!(f.buf, "{}{}fn{}{}",
match decl.purity {
ast::unsafe_fn => "unsafe ",
ast::extern_fn => "extern ",
ast::impure_fn => ""
},
PuritySpace(decl.purity),
match decl.abi {
~"" | ~"\"Rust\"" => ~"",
ref s => " " + *s + " ",
@ -362,3 +355,13 @@ impl fmt::Default for VisSpace {
}
}
}
impl fmt::Default for PuritySpace {
fn fmt(p: &PuritySpace, f: &mut fmt::Formatter) {
match **p {
ast::unsafe_fn => write!(f.buf, "unsafe "),
ast::extern_fn => write!(f.buf, "extern "),
ast::impure_fn => {}
}
}
}