From b8a9d5a9d9c0b8fe18f27a6c9c4049056adfe5e5 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sun, 20 Sep 2026 03:19:09 -0700 Subject: [PATCH] spam-filter: reach the &str by deref, not by str::as_str decancer 4.0 changes CuredString's Deref target from String to str. That is all it takes to break two call sites in the classifier: .as_str() used to resolve to String::as_str through one deref, and now resolves to the inherent str::as_str, which is still unstable (rust-lang #130366). Stable rustc rejects it, so the whole crate fails to compile -- the two E0658s that are currently red on the decancer bump in PR #4. Neither call site wanted an inherent method, only a &str. Deref coercion gives that under either target, so dropping the .as_str() fixes 4.0 and keeps 3.3.3 building; cargo check passes against both. The result is identical either way, so no behaviour changes here. Committed against 3.3.3, which is still what the lockfile pins. The bump itself stays PR #4's to carry, and rebases onto this. Translation::String going from Cow<'static, str> to CuredString, the other breaking change in the 4.0 notes, touches nothing: the type appears nowhere in the tree. --- crates/spam-filter/src/modules/classifier.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/spam-filter/src/modules/classifier.rs b/crates/spam-filter/src/modules/classifier.rs index 4637970..65fc21a 100644 --- a/crates/spam-filter/src/modules/classifier.rs +++ b/crates/spam-filter/src/modules/classifier.rs @@ -1136,7 +1136,7 @@ impl<'x> Tokens<'x> { { if word.len() > MAX_TOKEN_LENGTH { self.insert(Token::Word { - value: truncate_word(cured_word.as_str(), MAX_TOKEN_LENGTH) + value: truncate_word(&cured_word, MAX_TOKEN_LENGTH) .to_string() .into(), }); @@ -1282,7 +1282,6 @@ impl Token<'static> { } else if !is_ascii { let word: String = if let Ok(cured) = decancer::cure(s, decancer::Options::default()) { cured - .as_str() .chars() .filter(|ch| ch.is_alphabetic()) .take(MAX_TOKEN_LENGTH)