Make cfg_if uses more explicit and consistent
This commit changes most uses of cfg_if as follows:
- fallthrough `else` usage is avoided for architecture or OS specific
items
- a comment is added in the final `else` clause to signal intent someone
modifying
It is safer to omit items than include ones for the wrong platform or
architecture.
diff --git a/src/lib.rs b/src/lib.rs
index 57919c5..2593e3b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -258,8 +258,10 @@
if #[cfg(windows)] {
mod windows;
pub use windows::*;
- } else {
+ } else if #[cfg(unix)] {
mod unix;
pub use unix::*;
+ } else {
+ // Unknown target_family
}
}
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index ec0fe7c..e96f433 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -946,6 +946,6 @@
mod b64;
pub use self::b64::*;
} else {
- // unknown arch...
+ // Unknown target_arch
}
}
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 171889e..7d98ef4 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -86,6 +86,6 @@
mod x86_64;
pub use self::x86_64::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 139edf7..b633003 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -350,6 +350,6 @@
mod freebsdlike;
pub use self::freebsdlike::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs
index 1cd6eb8..1a2bdff 100644
--- a/src/unix/bsd/openbsdlike/mod.rs
+++ b/src/unix/bsd/openbsdlike/mod.rs
@@ -402,8 +402,10 @@
} else if #[cfg(target_os = "netbsd")] {
mod netbsd;
pub use self::netbsd::*;
- } else {
+ } else if #[cfg(target_os = "openbsd")] {
mod openbsd;
pub use self::openbsd::*;
+ } else {
+ // Unknown target_os
}
}
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 3ffb3b7..77b24f2 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -733,6 +733,6 @@
mod solaris;
pub use self::solaris::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index f039683..0a01bcc 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -657,6 +657,6 @@
mod b64;
pub use self::b64::*;
} else {
- // ...
+ // Unknown target_pointer_width
}
}
diff --git a/src/unix/notbsd/linux/musl/b32/mod.rs b/src/unix/notbsd/linux/musl/b32/mod.rs
index 668e8fc..ad74e88 100644
--- a/src/unix/notbsd/linux/musl/b32/mod.rs
+++ b/src/unix/notbsd/linux/musl/b32/mod.rs
@@ -38,5 +38,7 @@
} else if #[cfg(any(target_arch = "asmjs"))] {
mod asmjs;
pub use self::asmjs::*;
- } else { }
+ } else {
+ // Unknown target_arch
+ }
}
diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs
index 908fa40..b39ff68 100644
--- a/src/unix/notbsd/linux/other/b32/mod.rs
+++ b/src/unix/notbsd/linux/other/b32/mod.rs
@@ -90,6 +90,6 @@
mod powerpc;
pub use self::powerpc::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/linux/other/b64/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs
index 28d9e4d..663b093 100644
--- a/src/unix/notbsd/linux/other/b64/mod.rs
+++ b/src/unix/notbsd/linux/other/b64/mod.rs
@@ -25,8 +25,10 @@
} else if #[cfg(any(target_arch = "powerpc64"))] {
mod powerpc64;
pub use self::powerpc64::*;
- } else {
+ } else if #[cfg(any(target_arch = "x86_64"))] {
mod x86_64;
pub use self::x86_64::*;
+ } else {
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs
index 09d7e35..3ac57fe 100644
--- a/src/unix/notbsd/linux/other/mod.rs
+++ b/src/unix/notbsd/linux/other/mod.rs
@@ -491,6 +491,6 @@
mod b64;
pub use self::b64::*;
} else {
- // ...
+ // Unknown target_arch
}
}
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index 6106438..7cdd63c 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -133,6 +133,7 @@
} else if #[cfg(target_pointer_width = "64")] {
const ULONG_SIZE: usize = 64;
} else {
+ // Unknown target_pointer_width
}
}
@@ -680,6 +681,6 @@
mod android;
pub use self::android::*;
} else {
- // ...
+ // Unknown target_os
}
}
diff --git a/src/windows.rs b/src/windows.rs
index 3f7f160..21b6e13 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -72,9 +72,11 @@
if #[cfg(all(target_env = "gnu"))] {
pub const L_tmpnam: ::c_uint = 14;
pub const TMP_MAX: ::c_uint = 0x7fff;
- } else {
+ } else if #[cfg(all(target_env = "msvc"))] {
pub const L_tmpnam: ::c_uint = 260;
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
+ } else {
+ // Unknown target_env
}
}