about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-21 04:02:46 +0000
committerbors <bors@rust-lang.org>2023-05-21 04:02:46 +0000
commita11235d1bfc91b230d9af8a673867812750f7a73 (patch)
tree089258b2827f53cc76a80e655345baf0ebc7e351 /compiler
parent1b67f8b013890fec98e4a2e72b568731d3a58c1f (diff)
parent7cdb23b98a58a4e73ab1e4ca5e3bb7d04645bdd7 (diff)
downloadrust-a11235d1bfc91b230d9af8a673867812750f7a73.tar.gz
rust-a11235d1bfc91b230d9af8a673867812750f7a73.zip
Auto merge of #111696 - lukas-code:offset-of-erase-regions-harder, r=compiler-errors
don't skip inference for type in `offset_of!`

Fixes https://github.com/rust-lang/rust/issues/111678 by no longer skipping inference on the type in `offset_of!`. Simply erasing the regions the during writeback isn't enough and can cause ICEs. A test case for this is included.

This reverts https://github.com/rust-lang/rust/pull/111661, because it becomes redundant, since inference already erases the regions.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/writeback.rs10
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_rvalue.rs7
2 files changed, 4 insertions, 13 deletions
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index eed3c65eccc..a4c6dd4332a 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -692,15 +692,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
             fcx_typeck_results.offset_of_data().items_in_stable_order()
         {
             let hir_id = hir::HirId { owner: common_hir_owner, local_id };
-
-            if cfg!(debug_assertions) && container.has_infer() {
-                span_bug!(
-                    hir_id.to_span(self.fcx.tcx),
-                    "writeback: `{:?}` has inference variables",
-                    container
-                );
-            };
-
+            let container = self.resolve(container, &hir_id);
             self.typeck_results.offset_of_data_mut().insert(hir_id, (container, indices.clone()));
         }
     }
diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
index 0105a265ffb..c385b00692f 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
@@ -481,10 +481,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 }))))
             }
 
-            ExprKind::OffsetOf { container, fields } => block.and(Rvalue::NullaryOp(
-                NullOp::OffsetOf(fields),
-                this.tcx.erase_regions(container),
-            )),
+            ExprKind::OffsetOf { container, fields } => {
+                block.and(Rvalue::NullaryOp(NullOp::OffsetOf(fields), container))
+            }
 
             ExprKind::Literal { .. }
             | ExprKind::NamedConst { .. }