Allow impl Trait inside where clauses#105043
Allow impl Trait inside where clauses#105043bombless wants to merge 4 commits intorust-lang:masterfrom
impl Trait inside where clauses#105043Conversation
|
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.
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.
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.
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.
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