pub struct TypeMap<'ll, 'tcx> {
unique_id_interner: TypeIdInterner,
unique_id_to_metadata: FxHashMap<UniqueTypeId, &'ll DIType>,
type_to_metadata: FxHashMap<Ty<'tcx>, &'ll DIType>,
type_to_unique_id: FxHashMap<Ty<'tcx>, UniqueTypeId>,
}Expand description
The TypeMap is where the CrateDebugContext holds the type metadata nodes
created so far. The metadata nodes are indexed by UniqueTypeId, and, for
faster lookup, also by Ty. The TypeMap is responsible for creating
UniqueTypeIds.
Fields
unique_id_interner: TypeIdInternerThe UniqueTypeIds created so far.
unique_id_to_metadata: FxHashMap<UniqueTypeId, &'ll DIType>A map from UniqueTypeId to debuginfo metadata for that type. This is a 1:1 mapping.
type_to_metadata: FxHashMap<Ty<'tcx>, &'ll DIType>A map from types to debuginfo metadata. This is an N:1 mapping.
type_to_unique_id: FxHashMap<Ty<'tcx>, UniqueTypeId>A map from types to UniqueTypeId. This is an N:1 mapping.
Implementations
sourceimpl<'ll, 'tcx> TypeMap<'ll, 'tcx>
impl<'ll, 'tcx> TypeMap<'ll, 'tcx>
sourcefn register_type_with_metadata(
&mut self,
type_: Ty<'tcx>,
metadata: &'ll DIType
)
fn register_type_with_metadata(
&mut self,
type_: Ty<'tcx>,
metadata: &'ll DIType
)
Adds a Ty to metadata mapping to the TypeMap. The method will fail if the mapping already exists.
sourcefn remove_type(&mut self, type_: Ty<'tcx>)
fn remove_type(&mut self, type_: Ty<'tcx>)
Removes a Ty-to-metadata mapping.
This is useful when computing the metadata for a potentially
recursive type (e.g., a function pointer of the form:
fn foo() -> impl Copy { foo }This kind of type cannot be properly represented via LLVM debuginfo. As a workaround, we register a temporary Ty to metadata mapping for the function before we compute its actual metadata. If the metadata computation ends up recursing back to the original function, it will use the temporary mapping for the inner self-reference, preventing us from recursing forever.
This function is used to remove the temporary metadata mapping after we’ve computed the actual metadata.
sourcefn register_unique_id_with_metadata(
&mut self,
unique_type_id: UniqueTypeId,
metadata: &'ll DIType
)
fn register_unique_id_with_metadata(
&mut self,
unique_type_id: UniqueTypeId,
metadata: &'ll DIType
)
Adds a UniqueTypeId to metadata mapping to the TypeMap. The method will
fail if the mapping already exists.
fn find_metadata_for_type(&self, type_: Ty<'tcx>) -> Option<&'ll DIType>
fn find_metadata_for_unique_id(
&self,
unique_type_id: UniqueTypeId
) -> Option<&'ll DIType>
sourcefn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> &str
fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> &str
Gets the string representation of a UniqueTypeId. This method will fail if
the ID is unknown.
sourcefn get_unique_type_id_of_type<'a>(
&mut self,
cx: &CodegenCx<'a, 'tcx>,
type_: Ty<'tcx>
) -> UniqueTypeId
fn get_unique_type_id_of_type<'a>(
&mut self,
cx: &CodegenCx<'a, 'tcx>,
type_: Ty<'tcx>
) -> UniqueTypeId
Gets the UniqueTypeId for the given type. If the UniqueTypeId for the given
type has been requested before, this is just a table lookup. Otherwise, an
ID will be generated and stored for later lookup.
sourcefn get_unique_type_id_of_enum_variant<'a>(
&mut self,
cx: &CodegenCx<'a, 'tcx>,
enum_type: Ty<'tcx>,
variant_name: &str
) -> UniqueTypeId
fn get_unique_type_id_of_enum_variant<'a>(
&mut self,
cx: &CodegenCx<'a, 'tcx>,
enum_type: Ty<'tcx>,
variant_name: &str
) -> UniqueTypeId
Gets the UniqueTypeId for an enum variant. Enum variants are not really
types of their own, so they need special handling. We still need a
UniqueTypeId for them, since to debuginfo they are real types.
sourcefn get_unique_type_id_str_of_enum_variant_part(
&mut self,
enum_type_id: UniqueTypeId
) -> String
fn get_unique_type_id_str_of_enum_variant_part(
&mut self,
enum_type_id: UniqueTypeId
) -> String
Gets the unique type ID string for an enum variant part.
Variant parts are not types and shouldn’t really have their own ID,
but it makes set_members_of_composite_type() simpler.
Trait Implementations
Auto Trait Implementations
impl<'ll, 'tcx> !RefUnwindSafe for TypeMap<'ll, 'tcx>
impl<'ll, 'tcx> !Send for TypeMap<'ll, 'tcx>
impl<'ll, 'tcx> !Sync for TypeMap<'ll, 'tcx>
impl<'ll, 'tcx> Unpin for TypeMap<'ll, 'tcx>
impl<'ll, 'tcx> !UnwindSafe for TypeMap<'ll, 'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 200 bytes