summaryrefslogtreecommitdiff
path: root/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs')
-rw-r--r--rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
index 2403c879..f82174aa 100644
--- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
+++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
@@ -146,10 +146,27 @@ impl DebugInfoBuilder {
}
pub fn add_type(&mut self, type_uid: TypeUID, name: CString, t: Ref<Type>, commit: bool) {
- assert!(self
- .types
- .insert(type_uid, DebugType { name, t, commit })
- .is_none());
+ if let Some(DebugType {
+ name: existing_name,
+ t: existing_type,
+ commit: _,
+ }) = self.types.insert(
+ type_uid,
+ DebugType {
+ name: name.clone(),
+ t: t.clone(),
+ commit,
+ },
+ ) {
+ if existing_type != t {
+ error!("DWARF info contains duplicate type definition. Overwriting type `{}` (named `{:?}`) with `{}` (named `{:?}`)",
+ existing_type,
+ existing_name,
+ t,
+ name
+ );
+ }
+ }
}
// TODO : Non-copy?