Skip to content

rust: a weak boolean stored in a local and compared with true (let ok = x > 0; assert_eq!(ok, true)) reads exposed #16296

Done

Description

@EffortlessSteven

Gap

A test that stores a weak boolean in a local and then compares that local with true through an equality macro reads exposed. The same check written directly reads weak.

Subject: discount(amount) changes if amount > 100 to if amount >= 100, so discount(100) moves from 100 to 90. Each test body below passes on both versions. Probed with ripr check --mode ready on current main plus #16295:

test body class
let ok = matches!(discount(100), 90 | 100); assert_eq!(ok, true); exposed
let ok = matches!(discount(100), _); assert_eq!(ok, true); exposed
let ok = matches!(Some(discount(100)), Some(_)); assert_eq!(ok, true); exposed
let ok = discount(100) > 0; assert_eq!(ok, true); exposed
let ok = discount(100) != 95; assert_eq!(ok, true); exposed
let ok = matches!(discount(100), 90 | 100); assert!(ok); weakly_exposed
let ok = matches!(discount(100), 90 | 100); assert!(ok == true); weakly_exposed
let ok = discount(100) == 90 || discount(100) == 100; assert_eq!(ok, true); weakly_exposed
assert_eq!(matches!(discount(100), 90 | 100), true); (#16290) weakly_exposed
let ok = discount(100) > 0; assert!(ok); weakly_exposed

The related test reports assert_eq!(ok, true); as exact_value / strong. The assertion line alone has the shape of an exact pin, and the local's defining expression is never read, so a relational, inequality or pattern check stored in a bool counts as an exact pin of the owner's value.

Direction

When an equality assertion compares a test-local boolean with a boolean literal (assert_eq!(ok, true), either operand order, assert_ne!(ok, false)), read the local's single defining expression in the test body. Grade the assertion as RIPR-SPEC-0231 grades that expression written in place: rule 1 for comparisons and disjunctions, rule 3 for matches!. Some cases fail closed and give no exact credit: a local that is reassigned or shadowed, defined in another scope, or whose definition cannot be read.

Acceptance

  • Each exposed row above reads weakly_exposed. let ok = matches!(discount(100), 90); assert_eq!(ok, true); and let ok = discount(100) == 90; assert_eq!(ok, true); stay exposed.
  • An end-to-end test through check_workspace, plus an honesty corpus case for the relational row.
  • A non-boolean local (let v = discount(100); assert_eq!(v, 90);) is unchanged.

Generated by Claude Code

Activity

  1. EffortlessSteven commented on Nov 26, 2026

    @EffortlessSteven
    MemberAuthor

    Claim: this thread takes #16296 after #16295 lands. Both touch the same compared-boolean reading and bump the cache.

    • Branch: claude/project-thread-six0md
    • PR: none yet
    • State: investigating

    Generated by Claude Code

  2. added
    status/needs-work
    on Nov 26, 2026
  3. EffortlessSteven commented on Nov 26, 2026

    @EffortlessSteven
    MemberAuthor

    Delivered by #16301 (squash 3f546f6). A boolean local that is compared with a boolean literal, and that the function binds exactly once with a plain immutable let, now reads as its initializer written in place. The reading only ever lowers. Both the parser-macro path and the line-scanned path apply it. Cache generation is 1.205 / 0.207.

    How this is proven:

    • unit rows;
    • an e2e exposed/weakly_exposed pair per shape, including upper-case names;
    • the honesty-corpus case rust_repo_exposure_bool_local_compared_with_true_not_promoted.

    Identifier keys accept any spelling, raw r# included. NFC-equivalent spellings are deliberately left as they are, with reasoning on the PR thread. One related test, operator_call_credit, depended on the old leak. Its body now pins both ordering directions.


    Generated by Claude Code

  4. added a commit that references this issue on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfinding-qualityimplementation-slicestatus/needs-worktesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions