From 02d100569b88d1cf3382bb28a31cfa55ef199113 Mon Sep 17 00:00:00 2001 From: yowl Date: Mon, 5 Feb 2024 11:31:47 -0500 Subject: [PATCH] Add cloning for DWARF String attributes (#7858) * add cloning for String attributes * use into_owned instead of to_vec to avoid a clone if possible. --- crates/cranelift/src/debug/transform/attr.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/cranelift/src/debug/transform/attr.rs b/crates/cranelift/src/debug/transform/attr.rs index 13bf62e9fb..354bcdacef 100644 --- a/crates/cranelift/src/debug/transform/attr.rs +++ b/crates/cranelift/src/debug/transform/attr.rs @@ -95,7 +95,7 @@ where let addr = addr_tr.translate(u).unwrap_or(write::Address::Constant(0)); write::AttributeValue::Address(addr) } - AttributeValue::Block(d) => write::AttributeValue::Block(d.to_slice()?.to_vec()), + AttributeValue::Block(d) => write::AttributeValue::Block(d.to_slice()?.into_owned()), AttributeValue::Udata(u) => write::AttributeValue::Udata(u), AttributeValue::Data1(d) => write::AttributeValue::Data1(d), AttributeValue::Data2(d) => write::AttributeValue::Data2(d), @@ -295,6 +295,7 @@ where pending_di_refs.insert(current_scope_id, attr.name(), offset); continue; } + AttributeValue::String(d) => write::AttributeValue::String(d.to_slice()?.into_owned()), a => bail!("Unexpected attribute: {:?}", a), }; let current_scope = out_unit.get_mut(current_scope_id);