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!() +}