Closed
Description
For some reason, impl Trait
is allowed in a type's first mention but not in a where
clause.
use core::ops::Add;
// Allowed
fn foo<T: Add<Output = impl Default>>(t: T) {}
fn bar<T: AsRef<impl Default>>(t: T) {}
// Not allowed
fn another_foo<T>(t: T)
where
T: Add<Output = impl Default>,
{
}
fn another_bar<T>(t: T)
where
T: AsRef<impl Default>,
{
}
Besides, the error message isn't very helpful.
`impl Trait` only allowed in function and inherent method return types, not in *****bound***** (which bound?)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Confusing error or lint that should be reworked.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Help is requested to fix this issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.