What does this mean and how can I fix this warning?
warning: this function depends on never type fallback being `()`
--> src/service/redis_service.rs:31:5
|
31 | pub async fn set_str<V: AsRef<[u8]>>(&self, key: &str, value: V) -> Result<(), RedisErr> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: FromRedisValue` will fail
--> src/service/redis_service.rs:39:41
|
39 | let _ = &mut Self::init().await.set(key, &encoded)?;
| ^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
I figured out that I can fix this by adding let _: &mut () = &mut Self::init().await.set(key, &encoded)?; but this is way more confusing than before.
Ah so the return type is set by the type parameter RV: FromRedisValue and isn't otherwise constrained. I can reproduce the error in this self-contained program:
As to your actual question, here is how to properly and concisely constrain the return type to ():
let () = Self::init().await.set(key, &encoded)?;
It can also be written as:
() = Self::init().await.set(key, &encoded)?;
but I personally don’t care for that (it’s technically an assignment to a tuple of zero variables). In either case, the &mut was doing you no good but adding verbosity.