Skip to content

rust: drop(fs::..) discards errors that unused_result_ok cannot see #13352

Closed

Description

@TrapsterDK

Where

  • drop(std::fs::..) / drop(fs::..) discards a file-system error where clippy::unused_result_ok, clippy::map_err_ignore and the discards() check in tools/ci/lint_attributes_test.rs:161 cannot see it: 224 sites, 152 outside test files.
  • Largest groups outside tests: deploy/private (40), cli/setup (19), cli/plan (15), apple/private (13), tools/testing (12), cli/adopt (8), cli/cli (7), cli/process (6), cli/audit (4); e.g. cli/atomic_fs/src/lib.rs remove_stale_staging, android/private/packaging/ops/src/sign.rs:254, appimage/private/tools/packer/src/lib.rs:236.
  • As rust: stop discarding errors in cli/cli and deny unused_result_ok #13147 denies unused_result_ok per module, .ok(); on a removal can be rewritten as drop(..) and pass every check.

Fix

  • Shipped code: remove scratch files through a helper that ignores NotFound and logs any other error with the path (tracing::info!), or propagate the error where the removal matters. Test helpers may keep a best-effort removal but say why in a one-line comment.
  • Then extend discards() in tools/ci/lint_attributes_test.rs to reject drop(fs:: and drop(std::fs:: in shipped Rust, with a flag/pass unit test like flags_dropped_writes_and_ok_discards.
  • One PR per crate group, as in rust: stop discarding errors in cli/cli and deny unused_result_ok #13147.

Activity

  1. added
    enhancement
    P2
    on Nov 18, 2026
  2. TrapsterDK commented on Nov 18, 2026

    @TrapsterDK
    CollaboratorAuthor

    deploy/private group done in #13379 (helpers dx_atomic_fs::discard_file/discard_dir). Remaining:

    • Convert the other crate groups: cli/setup, cli/plan, apple/private, tools/testing, cli/adopt, cli/cli, cli/process, cli/audit, android/private/packaging/ops, appimage/private/tools/packer, and the rest (use the dx_atomic_fs helpers).
    • Then extend discards() in tools/ci/lint_attributes_test.rs to reject drop(fs:: / drop(std::fs:: with a flag/pass unit test.
  3. TrapsterDK commented on Nov 18, 2026

    @TrapsterDK
    CollaboratorAuthor

    #13403 covers cli/setup, cli/plan, cli/adopt, cli/process and cli/audit, and adds dx_atomic_fs::write_hint for best-effort hint writes. Still to do:

    • cli/env (29), tools/docs (20), cli/cli (17), tools/testing (13), apple/private (13), core/quality (3), cli/worktree (3), and the 1–2-site groups: tools/ci, cli/output, cli/ide, cli/advisory_prep, appimage/private, tools/coverage, cli/update, cli/ocaml_cc_driver, cli/depcheck, cli/atomic_fs, android/private.
    • Then extend discards() in tools/ci/lint_attributes_test.rs.

    Generated by Claude Code

  4. TrapsterDK commented on Nov 18, 2026

    @TrapsterDK
    CollaboratorAuthor

    #13409 covers cli/env, cli/cli and tools/testing. Still to do:


    Generated by Claude Code

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

    P2enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions