-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-edition-2024Area: The 2024 editionArea: The 2024 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.I-edition-triagedIssue: This issue has been reviewed and triaged by the Edition team.Issue: This issue has been reviewed and triaged by the Edition team.L-dependency_on_unit_never_type_fallbackLint: dependency_on_unit_never_type_fallbackLint: dependency_on_unit_never_type_fallbackT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
A-edition-2024Area: The 2024 editionArea: The 2024 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-editionDiagnostics: An error or lint that should account for edition differences.Diagnostics: An error or lint that should account for edition differences.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.I-edition-triagedIssue: This issue has been reviewed and triaged by the Edition team.Issue: This issue has been reviewed and triaged by the Edition team.L-dependency_on_unit_never_type_fallbackLint: dependency_on_unit_never_type_fallbackLint: dependency_on_unit_never_type_fallbackT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.