diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-06 23:53:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 23:53:18 +0200 |
| commit | 3a6f1b03757ce930ad0010e8d76cc0cf6518a535 (patch) | |
| tree | 21225b76270688091b6fc372a92e36f931c13d17 /compiler/rustc_mir_transform/src/gvn.rs | |
| parent | 2946ce29ed456df5664e315dee888902b7ac3ec5 (diff) | |
| parent | f9cf0964db531b234e374dfd6330e0aa0c427db0 (diff) | |
| download | rust-3a6f1b03757ce930ad0010e8d76cc0cf6518a535.tar.gz rust-3a6f1b03757ce930ad0010e8d76cc0cf6518a535.zip | |
Rollup merge of #142103 - scottmcm:fieldidx-in-interp, r=oli-obk
Update `InterpCx::project_field` to take `FieldIdx` As suggested by Ralf in https://github.com/rust-lang/rust/pull/142005#discussion_r2125839015
Diffstat (limited to 'compiler/rustc_mir_transform/src/gvn.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index a91d46ec406..92c30d239b5 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -438,8 +438,10 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { dest.clone() }; for (field_index, op) in fields.into_iter().enumerate() { - let field_dest = - self.ecx.project_field(&variant_dest, field_index).discard_err()?; + let field_dest = self + .ecx + .project_field(&variant_dest, FieldIdx::from_usize(field_index)) + .discard_err()?; self.ecx.copy_op(op, &field_dest).discard_err()?; } self.ecx @@ -1583,7 +1585,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { // We needed to check the variant to avoid trying to read the tag // field from an enum where no fields have variants, since that tag // field isn't in the `Aggregate` from which we're getting values. - Some((FieldIdx::from_usize(field_idx), field_layout.ty)) + Some((field_idx, field_layout.ty)) } else if let ty::Adt(adt, args) = ty.kind() && adt.is_struct() && adt.repr().transparent() |
