Merge pull request #80 from cassiersg/master

Fix #79
This commit is contained in:
Nick Cameron 2015-05-26 08:18:06 +12:00
commit ecd9557495
3 changed files with 29 additions and 1 deletions

View file

@ -27,6 +27,7 @@ impl<'a> FmtVisitor<'a> {
explicit_self: Option<&ast::ExplicitSelf>,
generics: &ast::Generics,
unsafety: &ast::Unsafety,
constness: &ast::Constness,
abi: &abi::Abi,
vis: ast::Visibility,
span_end: BytePos)
@ -40,6 +41,7 @@ impl<'a> FmtVisitor<'a> {
explicit_self,
generics,
unsafety,
constness,
abi,
vis,
span_end,
@ -74,6 +76,7 @@ impl<'a> FmtVisitor<'a> {
Some(&sig.explicit_self),
&sig.generics,
&sig.unsafety,
&sig.constness,
&sig.abi,
ast::Visibility::Inherited,
span_end,
@ -92,6 +95,7 @@ impl<'a> FmtVisitor<'a> {
explicit_self: Option<&ast::ExplicitSelf>,
generics: &ast::Generics,
unsafety: &ast::Unsafety,
constness: &ast::Constness,
abi: &abi::Abi,
vis: ast::Visibility,
span_end: BytePos,
@ -111,6 +115,9 @@ impl<'a> FmtVisitor<'a> {
if let &ast::Unsafety::Unsafe = unsafety {
result.push_str("unsafe ");
}
if let &ast::Constness::Const = constness {
result.push_str("const ");
}
if *abi != abi::Rust {
result.push_str("extern ");
result.push_str(&abi.to_string());

View file

@ -98,13 +98,19 @@ impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> {
let indent = self.block_indent;
match fk {
visit::FkItemFn(ident, ref generics, ref unsafety, ref abi, vis) => {
visit::FkItemFn(ident,
ref generics,
ref unsafety,
ref constness,
ref abi,
vis) => {
let new_fn = self.rewrite_fn(indent,
ident,
fd,
None,
generics,
unsafety,
constness,
abi,
vis,
b.span.lo);
@ -117,6 +123,7 @@ impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> {
Some(&sig.explicit_self),
&sig.generics,
&sig.unsafety,
&sig.constness,
&sig.abi,
vis.unwrap_or(ast::Visibility::Inherited),
b.span.lo);

View file

@ -58,6 +58,20 @@ pub fn render<'a,
render_opts(g, w, &[])
}
const fn foo() {
x;
}
pub const fn foo() {
x;
}
impl Foo {
const fn foo() {
x;
}
}
fn main() {
let _ = function(move || 5);
let _ = move || 42;