Skip to content

Commit 8a930fb

Browse files
committed
Check IO errors in test using raw_os_error() instead of kind()
std::io::ErrorKind is a `#[non_exhaustive]` enum as more specific error types are to be added in the future. It was unclear in the docs until very recently, however, that this is to be done by re-defining `ErrorKind::Other` errors to new enum variants. Thus, our tests which check explicitly for `ErrorKind::Other` as a result of trying to access a directory as a file were incorrect. Sadly, these generated no meaningful feedback from rustc at all, except that they're suddenly failing in rustc beta! After some back-and-forth, it seems rustc is moving forward breaking existing code in future versions, so we move to the "correct" check here, which is to check the raw IO error. See rust-lang/rust#86442 and rust-lang/rust#85746 for more info.
1 parent 0fa1865 commit 8a930fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning-persister/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ mod tests {
178178
match write_to_file(path, filename, &test_writeable) {
179179
Err(e) => {
180180
#[cfg(not(target_os = "windows"))]
181-
assert_eq!(e.kind(), io::ErrorKind::Other);
181+
assert_eq!(e.raw_os_error(), Some(libc::EISDIR));
182182
#[cfg(target_os = "windows")]
183183
assert_eq!(e.kind(), io::ErrorKind::PermissionDenied);
184184
}

0 commit comments

Comments
 (0)