-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Emit ForbiddenBound fatally if meeting complex bounds #149728
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
base: main
Are you sure you want to change the base?
Conversation
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
This comment has been minimized.
This comment has been minimized.
|
@rustbot reroll |
| // Issue #149695 | ||
| // Abort immediately otherwise items defined in complex bounds will be lowered into HIR, | ||
| // which will cause ICEs when errors of the items visit unlowered parents. | ||
| self.sess.dcx().emit_fatal(errors::ForbiddenBound { spans }); |
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.
fatal errors are a little unfortunate since they prevent other errors from happening. Is there no way to actually filter them out of the nested items? Maybe by setting a flag on the visitor?
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.
Sorry, I'm not sure what you mean. Did you mean skipping unlowered parents when visiting?
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.
well, if I understand it correctly, there are bounds in nested items, that if they remain there into the HIR will mess up type checking when finding those. So your solution is to error fatally early, so we never get to type checking. But that means you also don't get to see any other errors in the compilation process. Can we not filter out these bounds so they just won't go into HIR anymore? Or am I misunderstanding the situation and is that not easily possible?
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.
This ICE is because the error in the nested item needs visiting its parent which is complex bound contains nested items. Not due to bounds in nested items.
For the case in the issue:
#![feature(non_lifetime_binders)]
fn produce() -> for<A: A< {
#[derive(Hash)]
enum A {}
struct A<A>;
}
>> Trait{
}
fn main() {}Nested items in the complex bound for <A: A<{ ... }>> cause error and needs visiting its parent when reporting errors, and the parent points to the block in the trait ref. But we now won't lower the complex bound to hir, so that the block is not in hir also. And it's still the parent of the inner nested items, then ICE happens.
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.
So did you mean that don't lower nested items to hir if they are in a complex bound?
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.
IIUC, it may cause perf problem, because this needs checking whether an item is in a complex bound or not when lowering them, and lowering them is a separate procedure.
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.
could you try how bad that perf problem is? I'll start you a perf run. Cause I don't like the fatal errors much :/
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.
Ok, I will try to do that later
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.
thanks! If it does end up being terrible, we can go this route
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot review |
|
@rusbot author |
|
@rustbot blocked on #149728 (comment) |
|
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.
|
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.
You can check the previous attempt 1253837 |
|
@rustbot label -S-blocked |
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.
I think fixing this by aborting immediately when meeting complex bounds in binders is good enough.
Fixes #149695