Skip to content

Doctests as tests: should_panic examples and cfg-gated/split-doc edge cases still refuse or over-credit #8639

Closed

Description

@EffortlessSteven

Follow-up to #6648 (doctests credited as tests, RIPR-SPEC-0279, landed in #8572).

Gaps left after #8572 (all recorded as non-goals in docs/specs/RIPR-SPEC-0279-rust-doc-examples-as-tests.md or the #8572 review of record):

  1. should_panic doc examples are refused. rust: a doc example that cargo test runs is never read as an oracle, so doctest-only code reads weakly_exposed #6648 listed "plain fence, or should_panic" as expected; only the plain fence is credited. Repro: a pub fn in src/lib.rs whose only caller is a ```should_panic example that asserts on the panic path; expected a credited verdict only if the panic is the observed discriminator, otherwise unknown.
  2. Functions gated by feature / platform cfg / cfg(not(doctest)) register their doc examples like an ordinary #[test], though the doctest may not run in the default configuration (false-clean risk).
  3. /** */ block docs and a multi-line cfg_attr(..., doc = ...) above a /// run can still split one item's document, which the single-document rule is meant to refuse.
  4. Visibility of enclosing modules is not checked: a pub fn inside a private mod is still treated as a doctest subject.
  5. Display name omits the module path (<path> - <item> (line N)), so two same-named items in one file are told apart only by line.
  6. Indentation common to every doc line, and unclosed fences, are refused rather than parsed; a moved [lib] path loses doctest evidence.
  7. docs/PUBLIC_PROOF.md:381 may still list mined-doctest-only-read-u16 as false_actionable (the row now reads credited/ideal). Not touched in fix(rust): read runnable library doc examples as tests (#6648, RIPR-SPEC-0279) #8572 per the corpus-PR rule; regenerate with the public-proof refresh.

Goal hurt: trustworthy verdicts (2, 3, 4 are false-credit risks; 1, 5, 6 are missed credit).

Owner: analysis / test discovery (crates/ripr/src/analysis/facts/doctests.rs). A duplicate search for should_panic / doctest / cfg found nothing equivalent.

Activity

  1. EffortlessSteven commented on Nov 1, 2026

    @EffortlessSteven
    MemberAuthor

    Claim: wave-9A ITEM 4 — refuse cfg-gated doc examples and #![cfg(..)] files in doctest registration (#8639 item 2).

    State: implementing on branch cursor/doctest-cfg-gated-6c97.

    Files: crates/ripr/src/analysis/facts/doctests.rs, doctests/tests.rs, changelog.d/8639-doctest-cfg-gated.md.

  2. EffortlessSteven commented on Nov 1, 2026

    @EffortlessSteven
    MemberAuthor

    State: PR #12029 open at 2be4842f93 — implementation + tests complete; awaiting merge-ready label (agent 403) and Ripr Rust Small Result on that head.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions