Skip to content

Properly indent pub fns in extern blocks #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(";");
}
Expand Down
8 changes: 8 additions & 0 deletions tests/source/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 9 additions & 0 deletions tests/source/mod-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
9 changes: 9 additions & 0 deletions tests/target/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 10 additions & 0 deletions tests/target/mod-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
}