Skip to content

Commit 0878d65

Browse files
feat(style): enable and run cargo fmt
this PR updates the way mods are imported in src/device/mod to avoid a bug in cargo fmt that struggles with cfg_attr(path) (see: rust-lang/rustfmt#2407). once that bug was avoided, that allowed us to run cargo fmt. this PR includes those formatting updates and adds a cargo fmt check to CI.
1 parent e066960 commit 0878d65

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

ci/azure-build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ parameters:
55
steps:
66
- script: |
77
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
8+
export PATH=$PATH:$HOME/.cargo/bin
9+
rustup component add rustfmt
810
displayName: 'Install cargo'
911
- script: |
1012
export PATH=$PATH:$HOME/.cargo/bin
@@ -26,4 +28,8 @@ steps:
2628
- script: |
2729
export PATH=$PATH:$HOME/.cargo/bin
2830
cargo test --bin boringtun -- --test-threads=1
29-
displayName: 'Test executable'
31+
displayName: 'Test executable'
32+
- script: |
33+
export PATH=$PATH:$HOME/.cargo/bin
34+
cargo fmt --all -- --check
35+
displayName: 'Cargo fmt'

src/device/mod.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@ pub mod dev_lock;
77
pub mod drop_privileges;
88
mod integration_tests;
99
pub mod peer;
10-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "kqueue.rs")]
11-
#[cfg_attr(target_os = "linux", path = "epoll.rs")]
10+
11+
#[cfg(any(target_os = "macos", target_os = "ios"))]
12+
#[path = "kqueue.rs"]
13+
pub mod poll;
14+
15+
#[cfg(target_os = "linux")]
16+
#[path = "epoll.rs"]
1217
pub mod poll;
13-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "tun_darwin.rs")]
14-
#[cfg_attr(target_os = "linux", path = "tun_linux.rs")]
18+
19+
#[cfg(any(target_os = "macos", target_os = "ios"))]
20+
#[path = "tun_darwin.rs"]
1521
pub mod tun;
16-
#[cfg_attr(unix, path = "udp_unix.rs")]
22+
23+
#[cfg(target_os = "linux")]
24+
#[path = "tun_linux.rs"]
25+
pub mod tun;
26+
27+
#[cfg(unix)]
28+
#[path = "udp_unix.rs"]
1729
pub mod udp;
1830

1931
use crypto::x25519::*;

0 commit comments

Comments
 (0)