1
Fork 0

check if merged attributes list is empty

This commit is contained in:
Takayuki Maeda 2025-04-05 06:09:14 +09:00
parent ae9173d7dd
commit 6b5ccfc87f
3 changed files with 48 additions and 7 deletions

View file

@ -74,14 +74,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Merge attributes into the inner expression.
if !e.attrs.is_empty() {
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
self.attrs.insert(
ex.hir_id.local_id,
&*self.arena.alloc_from_iter(
self.lower_attrs_vec(&e.attrs, e.span)
.into_iter()
.chain(old_attrs.iter().cloned()),
),
let attrs = &*self.arena.alloc_from_iter(
self.lower_attrs_vec(&e.attrs, e.span)
.into_iter()
.chain(old_attrs.iter().cloned()),
);
if attrs.is_empty() {
return ex;
}
self.attrs.insert(ex.hir_id.local_id, attrs);
}
return ex;
}