Skip to content

Conversation

@wonkodv
Copy link
Contributor

@wonkodv wonkodv commented Jan 9, 2026

in LimitStack::pop_atr always call stack.pop().
It used to only be called inside a debug_assert! so the stack was not popped in release builds.

Running TESTNAME=cognitive_complexity cargo uitest --release used to print

error: there was 1 unmatched diagnostic
   --> tests/ui/cognitive_complexity.rs:121:4
    |
121 | fn bloo() {
    |    ^^^^ Error[clippy::cognitive_complexity]: the function has a cognitive complexity
 of (2/1)
    |      

The first commit adds to the ui test, which also fails in release, the 2nd commit fixes the tests.

changelog: [cognitive_complexity]: fix attribute stack not popping in release builds

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
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2026

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@llogiq llogiq added this pull request to the merge queue Jan 9, 2026
@llogiq
Copy link
Contributor

llogiq commented Jan 9, 2026

Thank you!

Merged via the queue into rust-lang:master with commit 11fe0c6 Jan 9, 2026
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants