From 700c3f69ed9b53a4e8ac80fe67507d71e247d67c Mon Sep 17 00:00:00 2001 From: Clyde Gerber Date: Sun, 19 Apr 2026 16:43:32 -0500 Subject: [PATCH 1/4] fix(rust_icu_udata): suppress dead_code warning for intentional keep-alive field Rep::Buffer(Vec) is never read, but exists solely to keep the buffer alive while ICU holds a raw pointer to it via udata_setCommonData. Annotate with #[allow(dead_code)] and document the intent to prevent the warning from being mistaken for a bug. This commit was created by an automated coding assistant, with human supervision. --- rust_icu_udata/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust_icu_udata/src/lib.rs b/rust_icu_udata/src/lib.rs index 10cb9a65..daab998f 100644 --- a/rust_icu_udata/src/lib.rs +++ b/rust_icu_udata/src/lib.rs @@ -24,6 +24,9 @@ use { #[derive(Debug)] enum Rep { /// The data memory is backed by a user-supplied buffer. + /// The Vec is never read; it exists solely to keep the buffer alive + /// while ICU holds a raw pointer to it via udata_setCommonData. + #[allow(dead_code)] Buffer(Vec), /// The data memory is backed by a resource file. Resource( From 601a97aec84110fce1757d7ebcea7ec5d38b0b26 Mon Sep 17 00:00:00 2001 From: Clyde Gerber Date: Sun, 19 Apr 2026 16:43:41 -0500 Subject: [PATCH 2/4] fix(rust_icu_ucnv): correct pivot buffer target pointer in reset functions reset_to_utf8 and reset_from_utf8 contained a copy-paste error where pivot_to_target and pivot_from_target were assigned to themselves instead of being reset to the start of their respective pivot buffers. This left the target pointer at its previous position after a reset, corrupting the pivot buffer state for subsequent conversions. This commit was created by an automated coding assistant, with human supervision. --- rust_icu_ucnv/src/utf8.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust_icu_ucnv/src/utf8.rs b/rust_icu_ucnv/src/utf8.rs index 52e1948b..c5808eb2 100644 --- a/rust_icu_ucnv/src/utf8.rs +++ b/rust_icu_ucnv/src/utf8.rs @@ -125,14 +125,14 @@ impl Converter { self.converter.reset_to_uchars(); self.utf8.reset_from_uchars(); self.pivot_to_source = self.pivot_to.start; - self.pivot_to_target = self.pivot_to_target; + self.pivot_to_target = self.pivot_to.start; } pub fn reset_from_utf8(&mut self) { self.utf8.reset_to_uchars(); self.converter.reset_from_uchars(); self.pivot_from_source = self.pivot_from.start; - self.pivot_from_target = self.pivot_from_target; + self.pivot_from_target = self.pivot_from.start; } pub fn feed_to_utf8(&mut self, dst: &mut [u8], src: &[u8]) -> FeedResult { From 4c069b93caf78cc5d8737cd9768afe6034e1d4fd Mon Sep 17 00:00:00 2001 From: Clyde Gerber Date: Sun, 19 Apr 2026 16:44:09 -0500 Subject: [PATCH 3/4] fix(rust_icu_ucsdet): use explicit anonymous lifetime in CharsetMatch return types The detect() and detect_all() methods returned CharsetMatch without its lifetime argument, while &self used the standard elided reference syntax. Using two different notations for the same lifetime is now flagged by the mismatched_lifetime_syntaxes lint. Annotate return types with CharsetMatch<'_> for consistency. This commit was created by an automated coding assistant, with human supervision. --- rust_icu_ucsdet/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust_icu_ucsdet/src/lib.rs b/rust_icu_ucsdet/src/lib.rs index eebdc8e7..a87ef9cd 100644 --- a/rust_icu_ucsdet/src/lib.rs +++ b/rust_icu_ucsdet/src/lib.rs @@ -111,7 +111,7 @@ impl<'detector> CharsetDetector<'detector> { } /// Return the charset that best matches the supplied input data. - pub fn detect(&self) -> Result { + pub fn detect(&self) -> Result, common::Error> { let mut status = sys::UErrorCode::U_ZERO_ERROR; let charset_match = unsafe { versioned_function!(ucsdet_detect)(self.rep.as_ptr(), &mut status) }; @@ -128,7 +128,7 @@ impl<'detector> CharsetDetector<'detector> { /// The results are ordered with the best quality match first. /// /// Returns `&[CharsetMatch]` if no error. - pub fn detect_all(&self) -> Result<&[CharsetMatch], common::Error> { + pub fn detect_all(&self) -> Result<&[CharsetMatch<'_>], common::Error> { let mut status = sys::UErrorCode::U_ZERO_ERROR; let mut len = 0; let charset_match = unsafe { From 586807fd67ee07fd5a2a34734c65c97e4daf1914 Mon Sep 17 00:00:00 2001 From: Clyde Gerber Date: Sun, 19 Apr 2026 16:47:58 -0500 Subject: [PATCH 4/4] fix(rust_icu_common): suppress dead_code warning in hygiene test The Type struct in hygiene.rs exists solely to verify that simple_drop_impl! expands correctly under #![no_implicit_prelude]. It is never constructed by design, so annotate it with #[allow(dead_code)]. This commit was created by an automated coding assistant, with human supervision. --- rust_icu_common/tests/hygiene.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust_icu_common/tests/hygiene.rs b/rust_icu_common/tests/hygiene.rs index 756ed310..038f0f20 100644 --- a/rust_icu_common/tests/hygiene.rs +++ b/rust_icu_common/tests/hygiene.rs @@ -1,5 +1,6 @@ #![no_implicit_prelude] +#[allow(dead_code)] struct Type { rep: ::std::ptr::NonNull<::rust_icu_sys::UMessageFormat>, }