Closed
Description
The dependency_on_unit_never_type_fallback
lint seems to provide a bad suggestion for an assignment to a wildcard pattern. Example (sorry, not minimized further, this is based on serde):
#![deny(dependency_on_unit_never_type_fallback)]
pub trait Deserialize: Sized {
fn deserialize<D>(deserializer: D) -> Result<Self, ()>
where
D: Deserializer;
}
pub trait Deserializer: Sized {}
pub trait MapAccess {
fn next_value<V>(&mut self) -> Result<V, ()>
where
V: Deserialize;
}
impl Deserialize for () {
fn deserialize<D>(_: D) -> Result<Self, ()>
where
D: Deserializer,
{
Ok(())
}
}
fn visit_map<A>(mut map: A) -> Result<i32, ()>
where
A: MapAccess,
{
_ = map.next_value()?;
Ok(1)
}
This gives a suggestion to modify it with:
@@ -29,7 +29,7 @@
where
A: MapAccess,
{
- _ = map.next_value()?;
+ _: () = map.next_value()?;
Ok(1)
}
This is not valid syntax, as an assignment expression does not allow qualifying with types.
In this case, I'm uncertain if the fallback can actually be a problem? If not, then maybe the lint shouldn't fire? Or if a type annotation is needed, then maybe use fully-qualified syntax?
Metadata
Metadata
Assignees
Labels
Area: The 2024 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: An error or lint that should account for edition differences.Diagnostics: A structured suggestion resulting in incorrect code.Lint: dependency_on_unit_never_type_fallbackRelevant to the compiler team, which will review and decide on the PR/issue.