Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

bombless
Copy link
Contributor

Fix #104526

@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2022

r? @nagisa

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2022

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

@rust-log-analyzer

This comment has been minimized.

Comment on lines 183 to 184
fn in_fn_where_clause()
where impl Debug: Debug
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

@bombless bombless Dec 6, 2022

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. 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. On second thought, this impl Default is associated with T already, so it's off-topic here, and it has its own unit test.

@bors
Copy link
Collaborator

bors commented Dec 15, 2022

☔ The latest upstream changes (presumably #105746) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa
Copy link
Member

nagisa commented Jan 9, 2023

r? rust-lang/compiler

@rustbot rustbot assigned TaKO8Ki and unassigned nagisa Jan 9, 2023
@compiler-errors
Copy link
Member

r? @compiler-errors
@rustbot author

@bombless what's the status on this? Can you rebase?

@rustbot rustbot assigned compiler-errors and unassigned TaKO8Ki Jan 25, 2023
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2023
@bombless
Copy link
Contributor Author

bombless commented Mar 2, 2023

I don't have time to finish the patch currently, so sorry I'm closing this PR

@bombless bombless closed this Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing impl Trait limitation
8 participants