Does not compile on rustc >= 1.92: dependency_on_unit_never_type_fallback is deny-by-default #2

Open
opened 2026-10-16 21:50:16 +00:00 by sammm · 0 comments
Owner

Problem

Since Rust 1.92 (Dec 2025), the lint dependency_on_unit_never_type_fallback is deny-by-default, and the crate no longer builds. On rustc 1.96.0:

error: this function depends on never type fallback being `()`
  --> src/redis_ctrl.rs:81:5
   |
81 |     fn set(&mut self, key: &str, value: &str) -> LJResult<()> {
   |
   = note: in edition 2024, the requirement `!: FromRedisValue` will fail

Same error in examples/simple_client.rs, examples/test.rs and examples/populate_redis.rs.

Cause

Nothing in the repo enables the lint (no [lints] table, no RUSTFLAGS) — it comes from the toolchain. The repo is edition 2021, but the lint now fires unconditionally: edition 2024 changes the never-type fallback from () to !, and this code depends on the old behaviour.

The trigger is the generic API of (crate rust) redis 0.23 : fn set<K, V, RV: FromRedisValue>(...). Called without annotation from a function returning Result<(), E>, inference falls back to RV = () — accepted for years, now denied.

Fix

The explicit annotations rustc suggests, nothing else:

// src/redis_ctrl.rs, impl KeyValueStore for RedisStore
Ok(self.connection.get::<_, Option<String>>(key)?)
self.connection.set::<_, _, ()>(key, value)?;
Ok(self.connection.set_nx::<_, _, bool>(key, value)?)
// examples/simple_client.rs, examples/test.rs (identical files), examples/populate_redis.rs
con.set::<_, _, ()>("/pl/0/0", format!("{:?}", v))?;
## Problem Since Rust 1.92 (Dec 2025), the lint `dependency_on_unit_never_type_fallback` is **deny-by-default**, and the crate no longer builds. On rustc 1.96.0: ``` error: this function depends on never type fallback being `()` --> src/redis_ctrl.rs:81:5 | 81 | fn set(&mut self, key: &str, value: &str) -> LJResult<()> { | = note: in edition 2024, the requirement `!: FromRedisValue` will fail ``` Same error in `examples/simple_client.rs`, `examples/test.rs` and `examples/populate_redis.rs`. ## Cause Nothing in the repo enables the lint (no `[lints]` table, no `RUSTFLAGS`) — it comes from the toolchain. The repo is edition 2021, but the lint now fires unconditionally: edition 2024 changes the never-type fallback from `()` to `!`, and this code depends on the old behaviour. The trigger is the generic API of (crate rust) `redis` 0.23 : `fn set<K, V, RV: FromRedisValue>(...)`. Called without annotation from a function returning `Result<(), E>`, inference falls back to `RV = ()` — accepted for years, now denied. ## Fix The explicit annotations rustc suggests, nothing else: ```rust // src/redis_ctrl.rs, impl KeyValueStore for RedisStore Ok(self.connection.get::<_, Option<String>>(key)?) self.connection.set::<_, _, ()>(key, value)?; Ok(self.connection.set_nx::<_, _, bool>(key, value)?) ``` ```rust // examples/simple_client.rs, examples/test.rs (identical files), examples/populate_redis.rs con.set::<_, _, ()>("/pl/0/0", format!("{:?}", v))?; ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
protonphoton/lj_rust#2
No description provided.