Skip to content
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

Don't ICE on return-type notation when promoting trait preds to associated type bounds #111861

Merged
merged 1 commit into from May 24, 2023

Conversation

compiler-errors
Copy link
Member

Fixes #111846

@rustbot
Copy link
Collaborator

rustbot commented May 23, 2023

r? @jackh726

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

@rustbot rustbot added 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 May 23, 2023
Comment on lines +430 to +431
// FIXME(return_type_notation): This check should be more robust
&& !tcx.is_impl_trait_in_trait(projection.def_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems just incomplete and a not so great hack.

If the return type is not an impl Trait, doesn't it work fine? If so, why?

If everything works as expected, this at least needs a bit more documentation on why this hack exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can encounter precisely two types of items for the projection.def_id here:

  1. Associated types/consts
  2. return-position impl trait in trait, when using RTN

If the return type is not an RPITIT, then it's always going to be an associated type or const, and the next line will never ICE. If the return type is an RPITIT, we shouldn't be calling associated_item on it, since that'll ICE.

When I mentioned that it should be more robust, I wasn't saying it was incomplete, I just don't really like that we have to treat associated items and RPITITs differently here (but this is a consequence of how they're currently implemented, and most code doesn't care about this distinction anyways).

@jackh726
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 23, 2023

📌 Commit e54bc1c has been approved by jackh726

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 24, 2023
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#111861 (Don't ICE on return-type notation when promoting trait preds to associated type bounds)
 - rust-lang#111864 (Always require closure parameters to be `Sized`)
 - rust-lang#111870 (Rename `traits_in_crate` query to `traits`)
 - rust-lang#111880 (Don't ICE when computing PointerLike trait when region vars are in param-env)
 - rust-lang#111887 (Add regression tests for pretty-printing inherent projections)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 224b651 into rust-lang:master May 24, 2023
11 checks passed
@rustbot rustbot added this to the 1.71.0 milestone May 24, 2023
@compiler-errors compiler-errors deleted the rtn-in-super branch August 11, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Return type notation ICEs on return position impl trait in trait
4 participants