Skip to content

Replace #[allow(...)] with #[expect(...)]#12788

Merged
davidpdrsn merged 1 commit intomasterfrom
dp-expect-allow
Mar 12, 2026
Merged

Replace #[allow(...)] with #[expect(...)]#12788
davidpdrsn merged 1 commit intomasterfrom
dp-expect-allow

Conversation

@davidpdrsn
Copy link
Contributor

expect works like allow except it fails if the lint isn't actually required. So helps to catch things like unnecessary #[allow(dead_code)].

Done with search-n-replace and having an agent fixing cargo clippy.

Copilot AI review requested due to automatic review settings March 11, 2026 21:46
@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Mar 12, 2026 7:37am

Request Review

@github-actions github-actions bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Mar 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens Rust lint suppression across the monorepo by replacing #[allow(...)] with #[expect(...)] (and removing some no-longer-needed suppressions), ensuring builds/clippy fail if a suppression becomes unnecessary.

Changes:

  • Replaced many #[allow(clippy::…)] with #[expect(clippy::…)] for argument-count, indexing/slicing, enum-size, and type-complexity lints.
  • Replaced/adjusted compiler-lint suppressions (e.g., dead_code, unused, unused_variables, invalid_from_utf8) to use #[expect(...)] where still required.
  • Removed a subset of #[allow(...)] attributes that no longer appear to be needed.

Reviewed changes

Copilot reviewed 43 out of 44 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/gitbutler-tauri/src/claude.rs Switches too_many_arguments suppression to #[expect] for a Tauri command.
crates/gitbutler-repo-actions/src/repository.rs Switches too_many_arguments suppression to #[expect] for a trait with wide APIs.
crates/but/vendor/cli-prompts/examples/general.rs Switches acronym naming suppression to #[expect] in a vendored example.
crates/but/src/command/legacy/status/mod.rs Switches too_many_arguments suppression to #[expect].
crates/but/src/command/legacy/status/json.rs Removes a too_many_arguments suppression that appears unnecessary.
crates/but/src/command/legacy/rub/squash.rs Switches too_many_arguments suppression to #[expect].
crates/but/src/command/legacy/rub/mod.rs Removes a private_interfaces suppression that appears unnecessary.
crates/but/src/command/legacy/forge/review.rs Switches multiple too_many_arguments suppressions to #[expect].
crates/but/src/command/legacy/diff/show.rs Switches large_enum_variant suppression to #[expect].
crates/but/src/command/legacy/branch/show.rs Removes a too_many_arguments suppression that appears unnecessary.
crates/but/src/command/legacy/branch/mod.rs Switches too_many_arguments suppression to #[expect].
crates/but/src/command/legacy/branch/list.rs Switches too_many_arguments suppressions to #[expect].
crates/but/src/command/legacy/absorb.rs Switches too_many_arguments suppression to #[expect].
crates/but-worktrees/tests/worktree/main.rs Switches unused suppression to #[expect] for test helper context.
crates/but-workspace/src/tree_manipulation/create_tree_without_diff.rs Removes a dead_code suppression that appears unnecessary.
crates/but-workspace/src/commit/mod.rs Switches indexing_slicing suppression to #[expect].
crates/but-workspace/src/branch/apply.rs Switches indexing_slicing suppression to #[expect].
crates/but-schemars/src/lib.rs Switches multiple dead_code suppressions to #[expect] for schema-only helper types.
crates/but-rebase/src/graph_rebase/mod.rs Removes an unused suppression that appears unnecessary.
crates/but-rebase/src/graph_rebase/cherry_pick.rs Switches too_many_arguments suppression to #[expect].
crates/but-project-handle/src/project_handle.rs Switches invalid_from_utf8 suppression to #[expect] in tests.
crates/but-meta/src/virtual_branches_legacy_types.rs Switches dead_code suppression to #[expect] for a serde helper variant.
crates/but-meta/src/legacy/storage.rs Switches large_enum_variant suppression to #[expect].
crates/but-link/tests/repo.rs Switches dead_code suppressions to #[expect] for test module includes.
crates/but-link/tests/payloads.rs Switches dead_code suppressions to #[expect] for test module includes.
crates/but-link/tests/db.rs Switches dead_code/unused_imports suppressions to #[expect] for test module includes.
crates/but-link/tests/cli.rs Switches dead_code suppression to #[expect] for test module include.
crates/but-link/tests/claiming.rs Switches dead_code/unused_imports suppressions to #[expect] for test module includes.
crates/but-hunk-dependency/tests/hunk_dependency/workspace_dependencies.rs Switches dead_code suppression to #[expect] in test util context.
crates/but-hunk-dependency/tests/hunk_dependency/ui.rs Switches dead_code suppression to #[expect] in test util context.
crates/but-hunk-dependency/src/ui.rs Switches dead_code suppression to #[expect] for schema-only helper type.
crates/but-gitlab/src/token.rs Removes dead_code suppressions on enum variants that appear unnecessary.
crates/but-github/src/token.rs Removes dead_code suppressions on enum variants that appear unnecessary.
crates/but-ctx/src/lib.rs Switches some type_complexity suppressions to #[expect] and removes others where unnecessary.
crates/but-core/src/worktree/checkout/tree.rs Switches indexing_slicing suppression to #[expect].
crates/but-core/src/tree/mod.rs Switches indexing_slicing suppression to #[expect].
crates/but-claude/src/session.rs Switches unused_variables suppression to #[expect] for a hook factory.
crates/but-claude/src/permissions/patterns.rs Removes a dead_code suppression that appears unnecessary.
crates/but-claude/src/claude_transcript.rs Switches large_enum_variant suppression to #[expect].
crates/but-bot/src/lib.rs Switches too_many_arguments suppression to #[expect].
crates/but-api/src/legacy/open.rs Switches unused_imports suppression to #[expect].
crates/but-api-macros/src/lib.rs Switches dead_code suppression to #[expect] for a helper function in macro expansion.
crates/but-action/src/lib.rs Switches too_many_arguments suppression to #[expect].
crates/but-action/src/auto_commit.rs Switches multiple too_many_arguments suppressions to #[expect].
Comments suppressed due to low confidence (1)

crates/but-claude/src/session.rs:1597

  • stack_id is passed into create_pretool_use_hook but never used. Instead of keeping an #[expect(unused_variables)] on the whole function, consider removing this parameter (and updating the call site) or renaming it to _stack_id and dropping the lint expectation.
#[expect(unused_variables)]
fn create_pretool_use_hook(
    sync_ctx: ThreadSafeContext,
    stack_id: but_core::ref_metadata::StackId,
) -> claude_agent_sdk_rs::HookCallback {

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

It would be great to have a clippy lint to enforce expect() over allow as well.

`expect` works like `allow` except it fails if the lint isn't actually
required. So helps to catch things like unnecessary `#[allow(dead_code)]`.
Copilot AI review requested due to automatic review settings March 12, 2026 07:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 44 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

@davidpdrsn davidpdrsn merged commit 0a44902 into master Mar 12, 2026
40 checks passed
@davidpdrsn davidpdrsn deleted the dp-expect-allow branch March 12, 2026 08:14
mtsgrd pushed a commit that referenced this pull request Mar 12, 2026
Replace `#[allow(...)]` with `#[expect(...)]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants