-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow impl Trait
inside where clauses
#105043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @nagisa (rustbot has picked a reviewer for you, use r? to override) |
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
This comment has been minimized.
This comment has been minimized.
fn in_fn_where_clause() | ||
where impl Debug: Debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I'm not sure this kind of bounds being allowed make much sense. What is the usecase for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just like fn f<T: Debug>() where T: Debug {}
.
I guess it's best to keep it this way to make it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but unlike fn f<T: Debug>
, given that this is a universal/"argument-position" impl Trait
, neither the caller nor the callee can use this impl Trait
(caller can't provide it, callee can't reference), so it's particularly limited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's a problem though.
I'll add a lint for it.
Also, what if we need a type somewhere that related to a trait, but we don't care what is the exact type, e.g. On second thought, this fn f<T>(v: T) where Result<impl Default, T>: Default {}
. I think it's also a valid use-case, even though it's a by-product of impl-trait.impl Default
is associated with T already, so it's off-topic here, and it has its own unit test.
☔ The latest upstream changes (presumably #105746) made this pull request unmergeable. Please resolve the merge conflicts. |
r? rust-lang/compiler |
r? @compiler-errors @bombless what's the status on this? Can you rebase? |
I don't have time to finish the patch currently, so sorry I'm closing this PR |
Fix #104526