-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix ProjectionElem validation #96856
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
It looks like this issue happened in #95320. I'm concerned that this hasn't been caught for months, I think there should be tests for the validator. |
This comment has been minimized.
This comment has been minimized.
cc @JakobDegen, this touches your field validation logic |
This comment has been minimized.
This comment has been minimized.
6af8f27
to
0924096
Compare
This comment has been minimized.
This comment has been minimized.
0924096
to
d47528a
Compare
This comment has been minimized.
This comment has been minimized.
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.
cc @oli-obk who reviewed my PR
match parent_ty.ty.kind() { | ||
|
||
let kind = match parent_ty.ty.kind() { | ||
ty::Opaque(def_id, _) => self.tcx.type_of(def_id).kind(), |
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.
Doesn't this at the very least need a .subst()
call with the substitutions from the Opaque
type? In any case though, I'm also concerned that this can lead to query cycles. Probably the fact that this is necessary at all is a sign of a problem elsewhere, I don't think Opaque
is supposed to be allowed to appear here. I'd run into this with SetDiscriminant
too a while back
let Some(layout) = self.tcx.generator_layout(*def_id) else { | ||
self.fail(location, format!("No generator layout for {:?}", parent_ty)); | ||
return; | ||
}; |
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.
Yeah, this is a good point, the previous version of this was wrong, got some wires crossed there. That being said, this causing query cycles is not indicative of a bug I think, it's sort of to be expected I think. Probably this just means we can't do any checking in this branch and should just skip it?
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.
The query cycle is because I messed up here, instead of going through a query, it should be getting the generator layout directly through the MIR body. I'll fix it soon.
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.
I don't see how. There's no guarantee that the body gives GeneratorInfo
for the generator type (and this can happen in practice if the generator resume
call is inlined)
Although, maybe it's possible to do "if GeneratorLayout
is unavailable from this body, get it via query." That still seems potentially subtle though...
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #97025) made this pull request unmergeable. Please resolve the merge conflicts. |
|
||
let kind = match parent_ty.ty.kind() { | ||
ty::Opaque(def_id, substs) => { | ||
self.tcx.type_of(def_id).subst(self.tcx, substs).kind() |
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.
that could cause query cycle if it were called before mir_borrowck
afaict 🤔
It's surprising to me that this doesn't already happen 😅 Do you know why this is fine?
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.
I have no idea how or why this works. It just looked correct and happened to work without breaking anything.
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.
@oli-obk do you have an opinion about that?
Ping from triage: FYI: when a PR is ready for review, send a message containing |
@drmeepster any updates on this? |
6fdc1bb
to
28d7fb0
Compare
This comment has been minimized.
This comment has been minimized.
c46c41b
to
03e0f5f
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
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.
some final nits, then r=me
thanks for the patience and good work 😅 ❤️
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 7ce85a4c14fad79f1734fcb311744089b7313ef7 has been approved by |
☔ The latest upstream changes (presumably #98206) made this pull request unmergeable. Please resolve the merge conflicts. |
while rebasing, can you also squash some of the commits? @bors delegate+ |
✌️ @drmeepster can now approve this pull request |
7ce85a4
to
a2799b2
Compare
@bors r=Icnr |
📌 Commit a2799b2 has been approved by |
…n, r=Icnr Fix ProjectionElem validation `TypeChecker::visit_projection_elem` was not actually being called.
…n, r=Icnr Fix ProjectionElem validation `TypeChecker::visit_projection_elem` was not actually being called.
…n, r=Icnr Fix ProjectionElem validation `TypeChecker::visit_projection_elem` was not actually being called.
Rollup of 8 pull requests Successful merges: - rust-lang#96856 (Fix ProjectionElem validation) - rust-lang#97711 (Improve soundness of rustc_arena) - rust-lang#98507 (Finishing touches for `#[expect]` (RFC 2383)) - rust-lang#98692 (rustdoc: Cleanup more FIXMEs) - rust-lang#98901 (incr: cache dwarf objects in work products) - rust-lang#98930 (Make MIR basic blocks field public) - rust-lang#98973 (Remove (unused) inherent impl anchors) - rust-lang#98981 ( Edit `rustc_mir_dataflow::framework` documentation ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
TypeChecker::visit_projection_elem
was not actually being called.