Merge pull request #474 from marcusklaas/fn-indent

Properly indent pub fns in extern blocks
This commit is contained in:
Nick Cameron 2015-10-18 15:19:32 +13:00
commit d7019ce897
6 changed files with 38 additions and 3 deletions

View File

@ -273,7 +273,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
let has_long_item = try_opt!(items.iter()
.map(|li| li.item.as_ref().map(|s| s.len() > 10))
.fold(Some(false),
|acc, x| acc.and_then(|y| x.map(|x| (x || y)))));
|acc, x| acc.and_then(|y| x.map(|x| x || y))));
let tactic = if has_long_item || items.iter().any(ListItem::is_multiline) {
definitive_tactic(&items, ListTactic::HorizontalVertical, max_item_width)

View File

@ -143,14 +143,13 @@ impl<'a> FmtVisitor<'a> {
// These are not actually rust functions,
// but we format them as such.
abi::Abi::Rust,
ast::Visibility::Inherited,
item.vis,
span,
false,
false);
match rewrite {
Some((new_fn, _)) => {
self.buffer.push_str(format_visibility(item.vis));
self.buffer.push_str(&new_fn);
self.buffer.push_str(";");
}

View File

@ -26,3 +26,11 @@ extern "C" {
fn foo (x: *const c_char , ... ) ->
libc::c_long;
}
extern {
pub fn freopen(filename: *const c_char, mode: *const c_char
, mode2: *const c_char
, mode3: *const c_char,
file: *mut FILE)
-> *mut FILE;
}

View File

@ -15,3 +15,12 @@ mod foo {
}
mod boxed { pub use std::boxed::{Box, HEAP}; }
mod x {
pub fn freopen(filename: *const c_char,
mode: *const c_char,
mode2: *const c_char,
mode3: *const c_char,
file: *mut FILE)
-> *mut FILE{}
}

View File

@ -36,3 +36,12 @@ extern {
fn foo(x: *const c_char, ...) -> libc::c_long;
}
extern {
pub fn freopen(filename: *const c_char,
mode: *const c_char,
mode2: *const c_char,
mode3: *const c_char,
file: *mut FILE)
-> *mut FILE;
}

View File

@ -24,3 +24,13 @@ mod foo {
mod boxed {
pub use std::boxed::{Box, HEAP};
}
mod x {
pub fn freopen(filename: *const c_char,
mode: *const c_char,
mode2: *const c_char,
mode3: *const c_char,
file: *mut FILE)
-> *mut FILE {
}
}