Emit ForbiddenBound for bounds of type params when parsing higher ranked binders#149728
Emit ForbiddenBound for bounds of type params when parsing higher ranked binders#149728mu001999 wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
This comment has been minimized.
This comment has been minimized.
|
@rustbot reroll |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot review |
|
@rusbot author |
|
@rustbot blocked on #149728 (comment) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hi @jdonszelmann, in the lastest rough change, I tried to filter nested items in the bound, and not lower them to hir.
But there still be errors, because they still have Concrete content of the new ICE is: |
|
I think at least it's more difficult than I expected. Do you have any suggestions? |
This comment has been minimized.
This comment has been minimized.
|
Maybe that's not great for perf, mostly in visiting all those extra nodes I'm afraid |
|
Yep, I think this adds excessive overhead to the hot path. |
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
another alternative would be to actually lower where-bounds on binders to the HIR, or to already error on them when creating the AST before we collect the I personally feel like erroring pre def-collection might be better 🤔 haven't interacted with this code much so I am not sure :> |
Make sense, I think I could move the check in |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
Fixes #149695
Bounds in binders are denied, hir items won't contain and index them. But nested items in the bounds will still be lowered to hir. And their parents, i.e., the block in bounds is not in hir. So that ICE happens when error handling requires visiting hir parents.
This PR collects hirless def ids and skips them when iterating parents.This PR checks such bounds used in higher ranked binders and emit error
ForbiddenBoundwhen parsing. And make sure no such bounds appear in hir.