Skip to content

Commit 5407202

Browse files
committed
Properly indent pub fns in extern blocks
1 parent 00aa232 commit 5407202

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
273273
let has_long_item = try_opt!(items.iter()
274274
.map(|li| li.item.as_ref().map(|s| s.len() > 10))
275275
.fold(Some(false),
276-
|acc, x| acc.and_then(|y| x.map(|x| (x || y)))));
276+
|acc, x| acc.and_then(|y| x.map(|x| x || y))));
277277

278278
let tactic = if has_long_item || items.iter().any(ListItem::is_multiline) {
279279
definitive_tactic(&items, ListTactic::HorizontalVertical, max_item_width)

src/items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,13 @@ impl<'a> FmtVisitor<'a> {
143143
// These are not actually rust functions,
144144
// but we format them as such.
145145
abi::Abi::Rust,
146-
ast::Visibility::Inherited,
146+
item.vis,
147147
span,
148148
false,
149149
false);
150150

151151
match rewrite {
152152
Some((new_fn, _)) => {
153-
self.buffer.push_str(format_visibility(item.vis));
154153
self.buffer.push_str(&new_fn);
155154
self.buffer.push_str(";");
156155
}

tests/source/extern.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ extern "C" {
2626
fn foo (x: *const c_char , ... ) ->
2727
libc::c_long;
2828
}
29+
30+
extern {
31+
pub fn freopen(filename: *const c_char, mode: *const c_char
32+
, mode2: *const c_char
33+
, mode3: *const c_char,
34+
file: *mut FILE)
35+
-> *mut FILE;
36+
}

tests/source/mod-1.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ mod foo {
1515
}
1616

1717
mod boxed { pub use std::boxed::{Box, HEAP}; }
18+
19+
mod x {
20+
pub fn freopen(filename: *const c_char,
21+
mode: *const c_char,
22+
mode2: *const c_char,
23+
mode3: *const c_char,
24+
file: *mut FILE)
25+
-> *mut FILE{}
26+
}

tests/target/extern.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ extern {
3636

3737
fn foo(x: *const c_char, ...) -> libc::c_long;
3838
}
39+
40+
extern {
41+
pub fn freopen(filename: *const c_char,
42+
mode: *const c_char,
43+
mode2: *const c_char,
44+
mode3: *const c_char,
45+
file: *mut FILE)
46+
-> *mut FILE;
47+
}

tests/target/mod-1.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ mod foo {
2424
mod boxed {
2525
pub use std::boxed::{Box, HEAP};
2626
}
27+
28+
mod x {
29+
pub fn freopen(filename: *const c_char,
30+
mode: *const c_char,
31+
mode2: *const c_char,
32+
mode3: *const c_char,
33+
file: *mut FILE)
34+
-> *mut FILE {
35+
}
36+
}

0 commit comments

Comments
 (0)