The package claims to respect OS_STR_BYTES_CHECKED_CONVERSIONS env variable, but it does not. Therefore we just revert a breaking commit: https://github.com/dylni/os_str_bytes/commit/5d6c29bbb Plus extra clean-up of the same. --- .home/.cargo/macports/os_str_bytes-6.1.0/src/lib.rs 2006-07-24 09:21:28.000000000 +0800 +++ .home/.cargo/macports/os_str_bytes-6.1.0/src/lib.rs 2026-01-06 22:24:53.000000000 +0800 @@ -191,50 +191,21 @@ use std::path::PathBuf; use std::result; -macro_rules! if_checked_conversions { +macro_rules! if_raw_str { ( $($item:item)+ ) => { $( - #[cfg(feature = "checked_conversions")] + #[cfg(feature = "raw_os_str")] $item )+ }; } -#[cfg(not(os_str_bytes_docs_rs))] -if_checked_conversions! { - const _: &str = env!( - "OS_STR_BYTES_CHECKED_CONVERSIONS", - "The 'OS_STR_BYTES_CHECKED_CONVERSIONS' environment variable must be \ - defined to use the 'checked_conversions' feature.", - ); -} - -#[rustfmt::skip] -macro_rules! deprecated_checked_conversion { - ( $message:expr , $item:item ) => { - #[cfg_attr( - not(feature = "checked_conversions"), - deprecated = $message - )] - $item - }; -} - macro_rules! expect_encoded { ( $result:expr ) => { $result.expect("invalid raw bytes") }; } -macro_rules! if_raw_str { - ( $($item:item)+ ) => { - $( - #[cfg(feature = "raw_os_str")] - $item - )+ - }; -} - #[cfg_attr( all(target_family = "wasm", target_os = "unknown"), path = "wasm/mod.rs" @@ -268,34 +239,8 @@ pub use raw_str::RawOsString; } -deprecated_checked_conversion! { - "use `OsStrBytes::assert_from_raw_bytes` or \ - `OsStringBytes::assert_from_raw_vec` instead, or enable the \ - 'checked_conversions' feature", - /// The error that occurs when a byte sequence is not representable in the - /// platform encoding. - /// - /// [`Result::unwrap`] should almost always be called on results containing - /// this error. It should be known whether or not byte sequences are - /// properly encoded for the platform, since [the module-level - /// documentation][encoding] discourages using encoded bytes in - /// interchange. Results are returned primarily to make panicking behavior - /// explicit. - /// - /// On Unix, this error is never returned, but [`OsStrExt`] or - /// [`OsStringExt`] should be used instead if that needs to be guaranteed. - /// - /// [encoding]: self#encoding - /// [`OsStrExt`]: ::std::os::unix::ffi::OsStrExt - /// [`OsStringExt`]: ::std::os::unix::ffi::OsStringExt - /// [`Result::unwrap`]: ::std::result::Result::unwrap - #[derive(Debug, Eq, PartialEq)] - #[cfg_attr( - os_str_bytes_docs_rs, - doc(cfg(feature = "checked_conversions")) - )] - pub struct EncodingError(imp::EncodingError); -} +#[derive(Debug, Eq, PartialEq)] +pub struct EncodingError(imp::EncodingError); impl Display for EncodingError { #[inline] @@ -364,9 +309,6 @@ where S: Into>; - deprecated_checked_conversion! { - "use `assert_from_raw_bytes` instead, or enable the \ - 'checked_conversions' feature", /// Converts a byte string into an equivalent platform-native string. /// /// [`assert_from_raw_bytes`] should almost always be used instead. For @@ -393,14 +335,9 @@ /// ``` /// /// [`assert_from_raw_bytes`]: Self::assert_from_raw_bytes - #[cfg_attr( - os_str_bytes_docs_rs, - doc(cfg(feature = "checked_conversions")) - )] - fn from_raw_bytes<'a, S>(string: S) -> Result> + fn from_raw_bytes<'a, S>(string: S) -> Result> where S: Into>; - } /// Converts a platform-native string into an equivalent byte string. /// @@ -504,41 +441,7 @@ #[track_caller] fn assert_from_raw_vec(string: Vec) -> Self; - deprecated_checked_conversion! { - "use `assert_from_raw_vec` instead, or enable the \ - 'checked_conversions' feature", - /// Converts a byte string into an equivalent platform-native string. - /// - /// [`assert_from_raw_vec`] should almost always be used instead. For - /// more information, see [`EncodingError`]. - /// - /// # Errors - /// - /// See documentation for [`EncodingError`]. - /// - /// # Examples - /// - /// ``` - /// use std::env; - /// use std::ffi::OsString; - /// # use std::io; - /// - /// use os_str_bytes::OsStringBytes; - /// - /// let os_string = env::current_exe()?; - /// let os_bytes = os_string.clone().into_raw_vec(); - /// assert_eq!(os_string, OsString::from_raw_vec(os_bytes).unwrap()); - /// # - /// # Ok::<_, io::Error>(()) - /// ``` - /// - /// [`assert_from_raw_vec`]: Self::assert_from_raw_vec - #[cfg_attr( - os_str_bytes_docs_rs, - doc(cfg(feature = "checked_conversions")) - )] - fn from_raw_vec(string: Vec) -> Result; - } + fn from_raw_vec(string: Vec) -> Result; /// Converts a platform-native string into an equivalent byte string. /// --- .home/.cargo/macports/os_str_bytes-6.1.0/src/raw_str.rs 2006-07-24 09:21:28.000000000 +0800 +++ .home/.cargo/macports/os_str_bytes-6.1.0/src/raw_str.rs 2026-01-06 22:26:32.000000000 +0800 @@ -31,11 +31,6 @@ use super::private; use super::Pattern; -if_checked_conversions! { - use super::EncodingError; - use super::Result; -} - #[cfg(not(feature = "memchr"))] fn find(string: &[u8], pat: &[u8]) -> Option { for i in 0..=string.len().checked_sub(pat.len())? { @@ -204,44 +199,6 @@ Self::from_inner(string) } - if_checked_conversions! { - /// Wraps a byte string, without copying or encoding conversion. - /// - /// [`assert_from_raw_bytes`] should almost always be used instead. For - /// more information, see [`EncodingError`]. - /// - /// # Errors - /// - /// See documentation for [`EncodingError`]. - /// - /// # Examples - /// - /// ``` - /// use std::env; - /// # use std::io; - /// - /// use os_str_bytes::RawOsStr; - /// - /// let os_string = env::current_exe()?.into_os_string(); - /// let raw = RawOsStr::new(&os_string); - /// assert_eq!(Ok(&*raw), RawOsStr::from_raw_bytes(raw.as_raw_bytes())); - /// # - /// # Ok::<_, io::Error>(()) - /// ``` - /// - /// [`assert_from_raw_bytes`]: Self::assert_from_raw_bytes - #[cfg_attr( - os_str_bytes_docs_rs, - doc(cfg(feature = "checked_conversions")) - )] - #[inline] - pub fn from_raw_bytes(string: &[u8]) -> Result<&Self> { - raw::validate_bytes(string) - .map(|()| Self::from_inner(string)) - .map_err(EncodingError) - } - } - /// Wraps a byte string, without copying or encoding conversion. /// /// # Safety @@ -1069,45 +1026,6 @@ Self(string) } - if_checked_conversions! { - /// Wraps a byte string, without copying or encoding conversion. - /// - /// [`assert_from_raw_vec`] should almost always be used instead. For - /// more information, see [`EncodingError`]. - /// - /// # Errors - /// - /// See documentation for [`EncodingError`]. - /// - /// # Examples - /// - /// ``` - /// use std::env; - /// # use std::io; - /// - /// use os_str_bytes::RawOsString; - /// - /// let os_string = env::current_exe()?.into_os_string(); - /// let raw = RawOsString::new(os_string); - /// let raw_clone = raw.clone(); - /// assert_eq!(Ok(raw), RawOsString::from_raw_vec(raw_clone.into_raw_vec())); - /// # - /// # Ok::<_, io::Error>(()) - /// ``` - /// - /// [`assert_from_raw_vec`]: Self::assert_from_raw_vec - #[cfg_attr( - os_str_bytes_docs_rs, - doc(cfg(feature = "checked_conversions")) - )] - #[inline] - pub fn from_raw_vec(string: Vec) -> Result { - raw::validate_bytes(&string) - .map(|()| Self(string)) - .map_err(EncodingError) - } - } - /// Wraps a byte string, without copying or encoding conversion. /// /// # Safety