Skip to content

Commit edfdc55

Browse files
committed
tidy
1 parent 458a144 commit edfdc55

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{iter, ptr};
66

77
use libc::{c_char, c_longlong, c_uint};
88
use 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};
1010
use rustc_codegen_ssa::traits::*;
1111
use rustc_hir::def::{CtorKind, DefKind};
1212
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
@@ -17,22 +17,22 @@ use rustc_middle::ty::{
1717
};
1818
use rustc_session::config::{self, DebugInfo, Lto};
1919
use rustc_span::symbol::Symbol;
20-
use rustc_span::{hygiene, FileName, FileNameDisplayPreference, SourceFile, DUMMY_SP};
20+
use rustc_span::{DUMMY_SP, FileName, FileNameDisplayPreference, SourceFile, hygiene};
2121
use rustc_symbol_mangling::typeid_for_trait_ref;
2222
use rustc_target::spec::DebuginfoKind;
2323
use smallvec::smallvec;
2424
use tracing::{debug, instrument};
2525

2626
use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
27+
use super::CodegenUnitDebugContext;
2728
use super::namespace::mangled_name_of_instance;
2829
use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
2930
use super::utils::{
30-
create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB,
31+
DIB, create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
3132
};
32-
use super::CodegenUnitDebugContext;
3333
use crate::common::{AsCCharPtr, CodegenCx};
3434
use crate::debuginfo::metadata::type_map::build_type_with_children;
35-
use crate::debuginfo::utils::{wide_pointer_kind, WidePtrKind};
35+
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
3636
use crate::llvm::debuginfo::{
3737
DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
3838
DebugNameTableKind,
@@ -191,49 +191,49 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
191191
);
192192

193193
/*
194-
This block differentiates between mutable/immutable AND ref/ptr.
195-
196-
References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
197-
of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
198-
are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
199-
ref-to-ptr's.
200-
201-
Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
202-
and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
203-
quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
204-
ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
205-
and on the debugger visualizer end, the scripts can "undo" that translation.
206-
207-
To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
208-
with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
209-
immutable reference applies the const modifier to the *pointee type*. When reversing the
210-
debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
211-
the pointer to the value. This is a **very** important distinction.
212-
213-
Here are some examples, the Rust representation is on the left and the debuginfo translation on
214-
the right
215-
216-
Cosnt vs Mut:
217-
*const T -> const T *
218-
*mut T -> T *
219-
220-
*const *const T -> const T *const *
221-
*mut *mut T -> T **
222-
223-
*mut *const T -> const T **
224-
*const *mut T -> T *const *
225-
226-
Nested References:
227-
&T -> const T &
228-
&&T -> const T *const &&
229-
&&&T -> const T &const *const &&
230-
&&&&T -> const T *const &&const *const &&
231-
232-
&mut T -> T &
233-
&mut &mut T -> T *&&
234-
&mut &mut &mut T -> T &*&&
235-
&mut &mut &mut &mut T -> T *&&*&&
236-
*/
194+
This block differentiates between mutable/immutable AND ref/ptr.
195+
196+
References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
197+
of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
198+
are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
199+
ref-to-ptr's.
200+
201+
Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
202+
and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
203+
quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
204+
ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
205+
and on the debugger visualizer end, the scripts can "undo" that translation.
206+
207+
To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
208+
with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
209+
immutable reference applies the const modifier to the *pointee type*. When reversing the
210+
debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
211+
the pointer to the value. This is a **very** important distinction.
212+
213+
Here are some examples, the Rust representation is on the left and the debuginfo translation on
214+
the right
215+
216+
Cosnt vs Mut:
217+
*const T -> const T *
218+
*mut T -> T *
219+
220+
*const *const T -> const T *const *
221+
*mut *mut T -> T **
222+
223+
*mut *const T -> const T **
224+
*const *mut T -> T *const *
225+
226+
Nested References:
227+
&T -> const T &
228+
&&T -> const T *const &&
229+
&&&T -> const T &const *const &&
230+
&&&&T -> const T *const &&const *const &&
231+
232+
&mut T -> T &
233+
&mut &mut T -> T *&&
234+
&mut &mut &mut T -> T &*&&
235+
&mut &mut &mut &mut T -> T *&&*&&
236+
*/
237237
let di_node = match (ptr_type.kind(), pointee_type.kind()) {
238238
// if we have a ref-to-ref, convert the inner ref to a ptr and the outter ref to an rvalue ref
239239
// and apply `const` to the inner ref's value and the inner ref itself as necessary
@@ -1009,8 +1009,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
10091009
codegen_unit_name: &str,
10101010
debug_context: &CodegenUnitDebugContext<'ll, 'tcx>,
10111011
) -> &'ll DIDescriptor {
1012-
use rustc_session::config::RemapPathScopeComponents;
10131012
use rustc_session::RemapFileNameExt;
1013+
use rustc_session::config::RemapPathScopeComponents;
10141014
let mut name_in_debuginfo = tcx
10151015
.sess
10161016
.local_crate_source_file()

0 commit comments

Comments
 (0)