@@ -6,7 +6,7 @@ use std::{iter, ptr};
66
77use libc:: { c_char, c_longlong, c_uint} ;
88use rustc_abi:: { Align , Size } ;
9- use rustc_codegen_ssa:: debuginfo:: type_names:: { cpp_like_debuginfo , VTableNameKind } ;
9+ use rustc_codegen_ssa:: debuginfo:: type_names:: { VTableNameKind , cpp_like_debuginfo } ;
1010use rustc_codegen_ssa:: traits:: * ;
1111use rustc_hir:: def:: { CtorKind , DefKind } ;
1212use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
@@ -23,15 +23,15 @@ use smallvec::smallvec;
2323use tracing:: { debug, instrument} ;
2424
2525use self :: type_map:: { DINodeCreationResult , Stub , UniqueTypeId } ;
26+ use super :: CodegenUnitDebugContext ;
2627use super :: namespace:: mangled_name_of_instance;
2728use super :: type_names:: { compute_debuginfo_type_name, compute_debuginfo_vtable_name} ;
2829use super :: utils:: {
29- create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB ,
30+ DIB , create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
3031} ;
31- use super :: CodegenUnitDebugContext ;
3232use crate :: common:: { AsCCharPtr , CodegenCx } ;
3333use crate :: debuginfo:: metadata:: type_map:: build_type_with_children;
34- use crate :: debuginfo:: utils:: { wide_pointer_kind , WidePtrKind } ;
34+ use crate :: debuginfo:: utils:: { WidePtrKind , wide_pointer_kind } ;
3535use crate :: llvm:: debuginfo:: {
3636 DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType , DebugEmissionKind ,
3737 DebugNameTableKind ,
@@ -190,49 +190,49 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
190190 ) ;
191191
192192 /*
193- This block differentiates between mutable/immutable AND ref/ptr.
194-
195- References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
196- of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
197- are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
198- ref-to-ptr's.
199-
200- Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
201- and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
202- quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
203- ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
204- and on the debugger visualizer end, the scripts can "undo" that translation.
205-
206- To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
207- with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
208- immutable reference applies the const modifier to the *pointee type*. When reversing the
209- debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
210- the pointer to the value. This is a **very** important distinction.
211-
212- Here are some examples, the Rust representation is on the left and the debuginfo translation on
213- the right
214-
215- Cosnt vs Mut:
216- *const T -> const T *
217- *mut T -> T *
218-
219- *const *const T -> const T *const *
220- *mut *mut T -> T **
221-
222- *mut *const T -> const T **
223- *const *mut T -> T *const *
224-
225- Nested References:
226- &T -> const T &
227- &&T -> const T *const &&
228- &&&T -> const T &const *const &&
229- &&&&T -> const T *const &&const *const &&
230-
231- &mut T -> T &
232- &mut &mut T -> T *&&
233- &mut &mut &mut T -> T &*&&
234- &mut &mut &mut &mut T -> T *&&*&&
235- */
193+ This block differentiates between mutable/immutable AND ref/ptr.
194+
195+ References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
196+ of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
197+ are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
198+ ref-to-ptr's.
199+
200+ Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
201+ and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
202+ quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
203+ ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
204+ and on the debugger visualizer end, the scripts can "undo" that translation.
205+
206+ To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
207+ with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
208+ immutable reference applies the const modifier to the *pointee type*. When reversing the
209+ debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
210+ the pointer to the value. This is a **very** important distinction.
211+
212+ Here are some examples, the Rust representation is on the left and the debuginfo translation on
213+ the right
214+
215+ Cosnt vs Mut:
216+ *const T -> const T *
217+ *mut T -> T *
218+
219+ *const *const T -> const T *const *
220+ *mut *mut T -> T **
221+
222+ *mut *const T -> const T **
223+ *const *mut T -> T *const *
224+
225+ Nested References:
226+ &T -> const T &
227+ &&T -> const T *const &&
228+ &&&T -> const T &const *const &&
229+ &&&&T -> const T *const &&const *const &&
230+
231+ &mut T -> T &
232+ &mut &mut T -> T *&&
233+ &mut &mut &mut T -> T &*&&
234+ &mut &mut &mut &mut T -> T *&&*&&
235+ */
236236 let di_node = match ( ptr_type. kind ( ) , pointee_type. kind ( ) ) {
237237 // if we have a ref-to-ref, convert the inner ref to a ptr and the outter ref to an rvalue ref
238238 // and apply `const` to the inner ref's value and the inner ref itself as necessary
@@ -1008,8 +1008,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
10081008 codegen_unit_name : & str ,
10091009 debug_context : & CodegenUnitDebugContext < ' ll , ' tcx > ,
10101010) -> & ' ll DIDescriptor {
1011- use rustc_session:: config:: RemapPathScopeComponents ;
10121011 use rustc_session:: RemapFileNameExt ;
1012+ use rustc_session:: config:: RemapPathScopeComponents ;
10131013 let mut name_in_debuginfo = tcx
10141014 . sess
10151015 . local_crate_source_file ( )
0 commit comments