From 5407202fdf357e4acfe0d06c0ade9662d0eaad5f Mon Sep 17 00:00:00 2001 From: Marcus Klaas Date: Fri, 16 Oct 2015 22:05:44 +0200 Subject: [PATCH] Properly indent pub fns in extern blocks --- src/expr.rs | 2 +- src/items.rs | 3 +-- tests/source/extern.rs | 8 ++++++++ tests/source/mod-1.rs | 9 +++++++++ tests/target/extern.rs | 9 +++++++++ tests/target/mod-1.rs | 10 ++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index db8e37c27e7..0e2648fbe21 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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) diff --git a/src/items.rs b/src/items.rs index 18b9118532c..49da3e5886f 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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(";"); } diff --git a/tests/source/extern.rs b/tests/source/extern.rs index 7d3d0de6200..e33b646b726 100644 --- a/tests/source/extern.rs +++ b/tests/source/extern.rs @@ -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; + } diff --git a/tests/source/mod-1.rs b/tests/source/mod-1.rs index 2efb8f538e5..5eb73cb5d4c 100644 --- a/tests/source/mod-1.rs +++ b/tests/source/mod-1.rs @@ -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{} +} diff --git a/tests/target/extern.rs b/tests/target/extern.rs index 164a6302bb4..35475660bae 100644 --- a/tests/target/extern.rs +++ b/tests/target/extern.rs @@ -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; +} diff --git a/tests/target/mod-1.rs b/tests/target/mod-1.rs index 8916c972ad1..02ce208ed4e 100644 --- a/tests/target/mod-1.rs +++ b/tests/target/mod-1.rs @@ -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 { + } +}