From f367d69c289726184eee5782fc49b9bdd028cb4f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Sep 2026 10:05:49 +0200 Subject: [PATCH 1/2] experient to understand MaybeDangling perf regression --- compiler/rustc_middle/src/ty/layout.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c18bf81121377..947211e43144e 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1169,6 +1169,7 @@ where if this.ty.is_like_maybe_dangling() && let Some(info) = result { + std::hint::cold_path(); result = Some(PointeeInfo { // Mark the pointer as raw // (thus removing noalias/readonly/etc in case of the llvm backend) From ec999ed5e6098a89e34c5a3b0a2c8858dcfa16ba Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Sep 2026 10:07:40 +0200 Subject: [PATCH 2/2] what if we remove this code entirely --- compiler/rustc_middle/src/ty/layout.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 947211e43144e..2738bbcca57a6 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1165,22 +1165,6 @@ where } } - // Patch result if we are a MaybeDangling-like type. - if this.ty.is_like_maybe_dangling() - && let Some(info) = result - { - std::hint::cold_path(); - result = Some(PointeeInfo { - // Mark the pointer as raw - // (thus removing noalias/readonly/etc in case of the llvm backend) - safe: None, - // Make sure we don't assert dereferenceability of the pointer. - size: Size::ZERO, - // Preserve the alignment assertion! That is required even inside `MaybeDangling`. - align: info.align, - }); - } - result } };