Skip to content

Commit b06b76f

Browse files
authored
Run cargo fmt. (#418)
* Run `cargo fmt`. * Modify the `connect_error` test to accept `NetworkUnreachable` errors. These errors were observed under FreeBSD in CI. * Fix MSRV compilation.
1 parent de1d389 commit b06b76f

6 files changed

Lines changed: 41 additions & 20 deletions

File tree

‎cap-fs-ext/src/dir_entry_ext.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use cap_primitives::fs::Metadata;
21
#[cfg(windows)]
32
use cap_primitives::fs::_WindowsDirEntryExt;
3+
use cap_primitives::fs::Metadata;
44
use std::io;
55

66
/// Extension trait for `DirEntry`.

‎cap-primitives/src/fs/mod.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ pub use canonicalize::canonicalize;
6464
pub use copy::copy;
6565
pub use create_dir::create_dir;
6666
pub use dir_builder::*;
67-
pub use dir_entry::DirEntry;
6867
#[cfg(windows)]
6968
pub use dir_entry::_WindowsDirEntryExt;
69+
pub use dir_entry::DirEntry;
7070
pub use dir_options::DirOptions;
7171
pub use file::FileExt;
72+
#[cfg(windows)]
73+
pub use file_type::_WindowsFileTypeExt;
7274
pub use file_type::FileType;
7375
#[cfg(any(unix, target_os = "vxworks", all(windows, windows_file_type_ext)))]
7476
pub use file_type::FileTypeExt;
75-
#[cfg(windows)]
76-
pub use file_type::_WindowsFileTypeExt;
7777
pub use follow_symlinks::FollowSymlinks;
7878
pub use hard_link::hard_link;
7979
pub use is_file_read_write::is_file_read_write;

‎tests/cap-net-ext-tcp-split.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ fn connect_error() {
6262
|| e.kind() == ErrorKind::InvalidInput
6363
|| e.kind() == ErrorKind::AddrInUse
6464
|| e.kind() == ErrorKind::AddrNotAvailable
65-
|| e.kind() == ErrorKind::TimedOut,
65+
|| e.kind() == ErrorKind::TimedOut
66+
// Rust >=1.83 adds `ErrorKind::NetworkUnreachable`.
67+
|| e.to_string().contains("network unreachable")
68+
|| e.to_string().contains("Network is unreachable"),
6669
"bad error: {} {:?}",
6770
e,
6871
e.kind()

‎tests/cap-net-ext-tcp.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ fn connect_error() {
5252
|| e.kind() == ErrorKind::InvalidInput
5353
|| e.kind() == ErrorKind::AddrInUse
5454
|| e.kind() == ErrorKind::AddrNotAvailable
55-
|| e.kind() == ErrorKind::TimedOut,
55+
|| e.kind() == ErrorKind::TimedOut
56+
// Rust >=1.83 adds `ErrorKind::NetworkUnreachable`.
57+
|| e.to_string().contains("network unreachable")
58+
|| e.to_string().contains("Network is unreachable"),
5659
"bad error: {} {:?}",
5760
e,
5861
e.kind()

‎tests/fs_additional.rs‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,17 +1386,29 @@ fn dotdot_slashdot_at_end_of_symlink_all_inside_dir() {
13861386
fn statat_slash() {
13871387
let tmpdir = tmpdir();
13881388

1389-
error_contains!(tmpdir.metadata("/"), "a path led outside of the filesystem");
1390-
error_contains!(
1391-
tmpdir.metadata("/foo"),
1392-
"a path led outside of the filesystem"
1393-
);
1394-
error_contains!(
1395-
tmpdir.symlink_metadata("/"),
1396-
"a path led outside of the filesyste"
1397-
);
1398-
error_contains!(
1399-
tmpdir.symlink_metadata("/foo"),
1400-
"a path led outside of the filesyste"
1401-
);
1389+
// FreeBSD 14+ uses `O_RESOLVE_BENEATH` which issues different errors.
1390+
#[cfg(target_os = "freebsd")]
1391+
{
1392+
error_contains!(tmpdir.metadata("/"), "Capabilities insufficient");
1393+
error_contains!(tmpdir.metadata("/foo"), "Capabilities insufficient");
1394+
error_contains!(tmpdir.symlink_metadata("/"), "Capabilities insufficient");
1395+
error_contains!(tmpdir.symlink_metadata("/foo"), "Capabilities insufficient");
1396+
}
1397+
1398+
#[cfg(not(target_os = "freebsd"))]
1399+
{
1400+
error_contains!(tmpdir.metadata("/"), "a path led outside of the filesystem");
1401+
error_contains!(
1402+
tmpdir.metadata("/foo"),
1403+
"a path led outside of the filesystem"
1404+
);
1405+
error_contains!(
1406+
tmpdir.symlink_metadata("/"),
1407+
"a path led outside of the filesyste"
1408+
);
1409+
error_contains!(
1410+
tmpdir.symlink_metadata("/foo"),
1411+
"a path led outside of the filesyste"
1412+
);
1413+
}
14021414
}

‎tests/net-tcp.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ fn connect_error() {
4949
|| e.kind() == ErrorKind::InvalidInput
5050
|| e.kind() == ErrorKind::AddrInUse
5151
|| e.kind() == ErrorKind::AddrNotAvailable
52-
|| e.kind() == ErrorKind::TimedOut,
52+
|| e.kind() == ErrorKind::TimedOut
53+
// Rust >=1.83 adds `ErrorKind::NetworkUnreachable`.
54+
|| e.to_string().contains("network unreachable")
55+
|| e.to_string().contains("Network is unreachable"),
5356
"bad error: {} {:?}",
5457
e,
5558
e.kind()

0 commit comments

Comments
 (0)