@@ -480,8 +480,7 @@ pub(crate) fn spanned_type_di_node<'ll, 'tcx>(
480480 } ,
481481 ty:: Tuple ( _) => build_tuple_type_di_node ( cx, unique_type_id) ,
482482 ty:: Pat ( base, _) => return type_di_node ( cx, base) ,
483- // FIXME(unsafe_binders): impl debug info
484- ty:: UnsafeBinder ( _) => unimplemented ! ( ) ,
483+ ty:: UnsafeBinder ( _) => build_unsafe_binder_type_di_node ( cx, t, unique_type_id) ,
485484 ty:: Alias ( ..)
486485 | ty:: Param ( _)
487486 | ty:: Bound ( ..)
@@ -1488,6 +1487,56 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14881487 . di_node
14891488}
14901489
1490+ /// Creates the debuginfo node for `unsafe<'a> T` binder types.
1491+ ///
1492+ /// We treat an unsafe binder like a struct with a single field named `inner`
1493+ /// rather than delegating to the inner type's DI node directly. This way the
1494+ /// debugger shows the binder's own type name, and the wrapped value is still
1495+ /// accessible through the `inner` field.
1496+ fn build_unsafe_binder_type_di_node < ' ll , ' tcx > (
1497+ cx : & CodegenCx < ' ll , ' tcx > ,
1498+ binder_type : Ty < ' tcx > ,
1499+ unique_type_id : UniqueTypeId < ' tcx > ,
1500+ ) -> DINodeCreationResult < ' ll > {
1501+ let ty:: UnsafeBinder ( inner) = binder_type. kind ( ) else {
1502+ bug ! (
1503+ "Only ty::UnsafeBinder is valid for build_unsafe_binder_type_di_node. Found {:?} instead." ,
1504+ binder_type
1505+ )
1506+ } ;
1507+ let inner_type = inner. skip_binder ( ) ;
1508+ let inner_type_di_node = type_di_node ( cx, inner_type) ;
1509+
1510+ let type_name = compute_debuginfo_type_name ( cx. tcx , binder_type, true ) ;
1511+ type_map:: build_type_with_children (
1512+ cx,
1513+ type_map:: stub (
1514+ cx,
1515+ Stub :: Struct ,
1516+ unique_type_id,
1517+ & type_name,
1518+ None ,
1519+ cx. size_and_align_of ( binder_type) ,
1520+ NO_SCOPE_METADATA ,
1521+ DIFlags :: FlagZero ,
1522+ ) ,
1523+ |cx, unsafe_binder_type_di_node| {
1524+ let inner_layout = cx. layout_of ( inner_type) ;
1525+ smallvec ! [ build_field_di_node(
1526+ cx,
1527+ unsafe_binder_type_di_node,
1528+ "inner" ,
1529+ inner_layout,
1530+ Size :: ZERO ,
1531+ DIFlags :: FlagZero ,
1532+ inner_type_di_node,
1533+ None ,
1534+ ) ]
1535+ } ,
1536+ NO_GENERICS ,
1537+ )
1538+ }
1539+
14911540/// Get the global variable for the vtable.
14921541///
14931542/// When using global variables, we may have created an addrspacecast to get a pointer to the
0 commit comments