Fix LimitStack::pop_attrs in release mode

The `LimitStack::pop_attrs` function used to pop from the stack in
`debug_assert_eq!` and check the value. The `pop` operation was therefore
only executed in debug builds, leading to an unbalanced stack in
release builds when attributes were present.

This change ensures the `pop` operation is always executed, by moving
it out of the debug-only assertion. The assertion is kept for debug
builds.

changelog: fix unbalanced stack in attributes
This commit is contained in:
Wonko
2026-01-09 13:43:55 +01:00
parent b022edce93
commit 13b82eb615
+4 -1
View File
@@ -159,7 +159,10 @@ pub fn push_attrs(&mut self, sess: &Session, attrs: &[impl AttributeExt], name:
}
pub fn pop_attrs(&mut self, sess: &Session, attrs: &[impl AttributeExt], name: Symbol) {
let stack = &mut self.stack;
parse_attrs(sess, attrs, name, |val| debug_assert_eq!(stack.pop(), Some(val)));
parse_attrs(sess, attrs, name, |val| {
let popped = stack.pop();
debug_assert_eq!(popped, Some(val));
});
}
}