]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_transform/src/lower_intrinsics.rs
Introduce NullOp::AlignOf
[rust.git] / compiler / rustc_mir_transform / src / lower_intrinsics.rs
index 2f89b041c27b1f7062502f547ef5efbb840ec0fa..5848163af72fc22b0cc2d09f56f5f308e445852d 100644 (file)
@@ -92,14 +92,19 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
                         // since their semantics depend on the value of overflow-checks flag used
                         // during codegen. Issue #35310.
                     }
-                    sym::size_of => {
+                    sym::size_of | sym::min_align_of => {
                         if let Some((destination, target)) = *destination {
                             let tp_ty = substs.type_at(0);
+                            let null_op = match intrinsic_name {
+                                sym::size_of => NullOp::SizeOf,
+                                sym::min_align_of => NullOp::AlignOf,
+                                _ => bug!("unexpected intrinsic"),
+                            };
                             block.statements.push(Statement {
                                 source_info: terminator.source_info,
                                 kind: StatementKind::Assign(Box::new((
                                     destination,
-                                    Rvalue::NullaryOp(NullOp::SizeOf, tp_ty),
+                                    Rvalue::NullaryOp(null_op, tp_ty),
                                 ))),
                             });
                             terminator.kind = TerminatorKind::Goto { target };