Closed
Description
The dependency_on_unit_never_type_fallback
lint seems to provide a bad suggestion to include too many generic arguments when the function being called uses APIT. Example:
#![warn(rust_2024_compatibility)]
pub fn foo<T: Default>(_y: impl Fn()) -> Result<T, ()> {
Err(())
}
pub fn bar() -> Result<(), ()> {
foo(|| {})?;
Ok(())
}
Here this suggests the following change:
@@ -5,6 +5,6 @@
}
pub fn bar() -> Result<(), ()> {
- foo(|| {})?;
+ foo::<(), _>(|| {})?;
Ok(())
}
However, this fails to compile because the function only takes one generic argument. The correct suggestion would be just ::<()>
.
Meta
rustc 1.85.0-nightly (c44b3d50f 2024-12-03)
binary: rustc
commit-hash: c44b3d50fea96a3e0417e8264c16ea21a0a3fca2
commit-date: 2024-12-03
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4
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`Category: This is a bug.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.