mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
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:
@@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user