Skip to content

Commit dd308f9

Browse files
committed
fmt: Use vertical import formatting within libc
The crate has a lot of reexports and will be getting many more. Change the formatting to vertical to reduce the possibility of conflicts. (backport <#4772>) (cherry picked from commit c04afc0)
1 parent 9058efa commit dd308f9

File tree

41 files changed

+220
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+220
-46
lines changed

ci/style.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ while IFS= read -r file; do
4040
# Format the file. We need to invoke `rustfmt` directly since `cargo fmt`
4141
# can't figure out the module tree with the hacks in place.
4242
failed=false
43-
rustfmt --config-path rustfmt.toml "$file" ${check:+"$check"} || failed=true
43+
rustfmt "$file" ${check:+"$check"} || failed=true
4444

4545
# Restore all changes to the files.
4646
perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file"

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note that there is a separate configuration for `src/`
12
edition = "2021"
23
error_on_line_overflow = true
34
group_imports = "StdExternalCrate"

src/macros.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,59 @@ macro_rules! prelude {
7676
#[allow(unused_imports)]
7777
pub(crate) use core::default::Default;
7878
#[allow(unused_imports)]
79-
pub(crate) use core::marker::{Copy, Send, Sync};
79+
pub(crate) use core::marker::{
80+
Copy,
81+
Send,
82+
Sync,
83+
};
8084
#[allow(unused_imports)]
8185
pub(crate) use core::option::Option;
8286
#[allow(unused_imports)]
8387
pub(crate) use core::prelude::v1::derive;
8488
#[allow(unused_imports)]
85-
pub(crate) use core::{fmt, hash, iter, mem, ptr};
89+
pub(crate) use core::{
90+
fmt,
91+
hash,
92+
iter,
93+
mem,
94+
ptr,
95+
};
8696

8797
#[allow(unused_imports)]
8898
pub(crate) use fmt::Debug;
8999
#[allow(unused_imports)]
90-
pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val};
100+
pub(crate) use mem::{
101+
align_of,
102+
align_of_val,
103+
size_of,
104+
size_of_val,
105+
};
91106

92107
#[allow(unused_imports)]
93-
pub(crate) use crate::types::{CEnumRepr, Padding};
108+
pub(crate) use crate::types::{
109+
CEnumRepr,
110+
Padding,
111+
};
94112
// Commonly used types defined in this crate
95113
#[allow(unused_imports)]
96114
pub(crate) use crate::{
97-
c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint,
98-
c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t,
115+
c_char,
116+
c_double,
117+
c_float,
118+
c_int,
119+
c_long,
120+
c_longlong,
121+
c_short,
122+
c_uchar,
123+
c_uint,
124+
c_ulong,
125+
c_ulonglong,
126+
c_ushort,
127+
c_void,
128+
intptr_t,
129+
size_t,
130+
ssize_t,
131+
uintptr_t,
99132
};
100133
}
101134
};

src/rustfmt.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Note that there is a separate top-level configuration for everything else
2+
edition = "2021"
3+
error_on_line_overflow = true
4+
group_imports = "StdExternalCrate"
5+
imports_granularity = "Module"
6+
# This crate gets large lists of reexports. Use vertical to reduce conflicts.
7+
imports_layout = "Vertical"

src/unix/aix/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::prelude::*;
2-
use crate::{in_addr_t, in_port_t};
2+
use crate::{
3+
in_addr_t,
4+
in_port_t,
5+
};
36

47
pub type caddr_t = *mut c_char;
58
pub type clockid_t = c_longlong;

src/unix/bsd/apple/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
//! This covers *-apple-* triples currently
44
55
use crate::prelude::*;
6-
use crate::{cmsghdr, off_t};
6+
use crate::{
7+
cmsghdr,
8+
off_t,
9+
};
710

811
pub type wchar_t = i32;
912
pub type clock_t = c_ulong;

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::prelude::*;
2-
use crate::{cmsghdr, off_t};
2+
use crate::{
3+
cmsghdr,
4+
off_t,
5+
};
36

47
pub type dev_t = u32;
58
pub type wchar_t = i32;

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::prelude::*;
2-
use crate::{cmsghdr, off_t};
2+
use crate::{
3+
cmsghdr,
4+
off_t,
5+
};
36

47
pub type fflags_t = u32;
58

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::prelude::*;
2-
use crate::{cmsghdr, off_t};
2+
use crate::{
3+
cmsghdr,
4+
off_t,
5+
};
36

47
pub type clock_t = c_uint;
58
pub type suseconds_t = c_int;

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::prelude::*;
22
use crate::unix::bsd::O_SYNC;
3-
use crate::{cmsghdr, off_t};
3+
use crate::{
4+
cmsghdr,
5+
off_t,
6+
};
47

58
pub type clock_t = i64;
69
pub type suseconds_t = c_long;

0 commit comments

Comments
 (0)