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.
This commit is contained in:
2026-09-20 03:19:09 -07:00
parent 604d889220
commit b8a9d5a9d9
+1 -2
View File
@@ -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)