Open
Description
The following in 2021:
#![warn(dependency_on_unit_never_type_fallback)]
pub fn foo<T: Default>() -> Result<T, ()> {
Err(())
}
macro_rules! m {
($x: ident) => {
pub fn test() -> Result<(), ()> {
$x()?;
Ok(())
}
};
}
m!(foo);
produces a suggestion that results in the following change:
@@ -13,6 +13,6 @@
};
}
-m!(foo);
+m!(foo::<()>);
However, this is not valid because foo::<()>
is not an ident, and you get an error about no rules matching.
Possible solutions
I don't know if this is fixable, since I can't think of a suggestion that would actually be valid in this scenario. At a minimum, I would say that it should not give a suggestion in this scenario (or at least make it MaybeIncorrect).
Meta
rustc 1.85.0-nightly (7442931d4 2024-11-30)
binary: rustc
commit-hash: 7442931d49b199ad0a1cc0f8ca54e327b5139b66
commit-date: 2024-11-30
host: aarch64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4
Metadata
Metadata
Assignees
Labels
Area: The 2024 editionArea: 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.Issue: This issue has been reviewed and triaged by the Edition team.Lint: dependency_on_unit_never_type_fallbackRelevant to the compiler team, which will review and decide on the PR/issue.