Repository navigation
typeck: Fix ICE with struct update syntax - #50643
Conversation
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
Nominating for beta, this fixes a regression. |
oli-obk
left a comment
There was a problem hiding this comment.
Please add the test case from the issue as a ui test with a // compile-pass comment to ensure that we don't regress this in the future
There was a problem hiding this comment.
This check aborts in more cases than necessary (as shown by the failing tests).
You replace the any-closure's body with
let hir_id = self.tcx().hir.node_to_hir_id(f.id);
self.mc.tables.field_indices().get(hir_id).cloned().map_or(true, |idx| ixd == f_index)Which is essentially the body of the field_index function, but without the panic. Definitely keep the above comment and maybe add a note as to why we can't use the field_index function.
|
@oli-obk I should have commented on the PR as well. I posted on the issue that after looking at this again, I'm not sure that this is the correct approach. I think the real problem is here. Which is the reason why the example only hits the ICE if struct update syntax is used. I think a better fix would be to only use the
Will do. |
|
I have a working example of this that doesn't hit the ICE. I'm just running some tests to make sure I didn't break anything else 😄 |
If check_expr_struct_fields fails, do not continue to record update. If we continue to record update, the struct may cause us to ICE later on indexing a field that may or may not exist.
|
Updated to fix the problem in |
|
Nice! The new fix is much cleaner, I agree @bors r+ |
|
📌 Commit f6a46cf has been approved by |
|
@bors p=3 |
typeck: Fix ICE with struct update syntax If check_expr_struct_fields fails, do not continue to record update. If we continue to record update, the struct may cause us to ICE later on indexing a field that may or may not exist. Fixes: #50618
|
☀️ Test successful - status-appveyor, status-travis |
[beta] Process backports * #50622: rustc: leave space for fields of uninhabited types to allow partial initialization. * #50643: typeck: Fix ICE with struct update syntax r? @alexcrichton
If check_expr_struct_fields fails, do not continue to record update.
If we continue to record update, the struct may cause us to ICE later
on indexing a field that may or may not exist.
Fixes: #50618