From 3a364c4ea07b372b1454c9b8f18260193f565ff7 Mon Sep 17 00:00:00 2001 From: Amirhossein Akhlaghpour Date: Mon, 20 Jul 2026 21:00:46 +0330 Subject: [PATCH] fix: debuginfo generation for unsafe binders Signed-off-by: Amirhossein Akhlaghpour --- compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 2 +- .../debuginfo-escaping-bound-vars-issue-159576.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 18f44afa92e45..6e64fa7d04a93 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1635,7 +1635,7 @@ fn build_unsafe_binder_type_di_node<'ll, 'tcx>( binder_type ) }; - let inner_type = inner.skip_binder(); + let inner_type = cx.tcx.instantiate_bound_regions_with_erased((*inner).into()); let inner_type_di_node = type_di_node(cx, inner_type); let type_name = compute_debuginfo_type_name(cx.tcx, binder_type, true); diff --git a/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs b/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs new file mode 100644 index 0000000000000..269eecf0df0cd --- /dev/null +++ b/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs @@ -0,0 +1,9 @@ +//@ check-pass +//@ compile-flags: --crate-type=lib -Cdebuginfo=2 + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +pub fn woof() -> unsafe<'a, 'b> &'b Box &'a isize>)> { + todo!() +}