Skip to content

[Repo Assist] fix(rust-guard): remove redundant match arm and unused MEDIUM_BUFFER_SIZE re-export#3701

Merged
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-3691-rust-dead-code-e5261bae22aade86
Apr 13, 2026
Merged

[Repo Assist] fix(rust-guard): remove redundant match arm and unused MEDIUM_BUFFER_SIZE re-export#3701
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-3691-rust-dead-code-e5261bae22aade86

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Closes #3691

Root Cause

Two pieces of dead code identified in the Rust guard:

  1. collaborator_permission_floor (helpers.rs): The "none" => vec![] arm is unreachable — the wildcard _ => vec![] arm immediately below it returns the same value and Rust evaluates match arms top-to-bottom, so "none" would never reach the explicit arm anyway. This creates reader confusion about whether "none" has special semantics.

  2. MEDIUM_BUFFER_SIZE re-export (labels/mod.rs): This constant was re-exported speculatively "for backward compatibility" but is never consumed externally — backend.rs already imports it directly from super::constants. The re-export required a #[allow(unused_imports)] suppression, which is itself a code smell.

Changes

  • helpers.rs: Collapse the dead "none" => vec![] arm into the wildcard; add inline comment // "none" or any unrecognised value → no integrity to preserve the documented intent.
  • labels/mod.rs: Remove the MEDIUM_BUFFER_SIZE pub use and its #[allow(unused_imports)] annotation (3 lines removed).

Behaviour

No behaviour change. The "none" permission value continues to return vec![], the same result as before. All existing tests (including test_collaborator_permission_floor_none) pass unchanged.

Test Status

cargo test (guards/github-guard/rust-guard)
test result: ok. 279 passed; 0 failed; 0 ignored

Go build skipped (Go 1.25.0 toolchain not locally available in CI environment — infrastructure limitation unrelated to these Rust-only changes).

Generated by Repo Assist · ● 2.7M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

…SIZE re-export

In collaborator_permission_floor (helpers.rs), collapse the dead
same value. Add an inline comment to preserve the intent.

In labels/mod.rs, remove the speculative MEDIUM_BUFFER_SIZE re-export
that was never consumed externally (backend.rs already imports it
directly from super::constants). Deletes the #[allow(unused_imports)]
suppression alongside it.

Closes #3691

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review April 13, 2026 14:36
@lpcox lpcox merged commit d367cbd into main Apr 13, 2026
3 checks passed
Copilot AI review requested due to automatic review settings April 13, 2026 14:36
@lpcox lpcox deleted the repo-assist/fix-issue-3691-rust-dead-code-e5261bae22aade86 branch April 13, 2026 14:36
Copy link
Copy Markdown
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

Removes minor dead/redundant code from the Rust guard labeling module to simplify logic and shrink unnecessary API surface.

Changes:

  • Simplify collaborator_permission_floor by collapsing a redundant "none" match arm into the wildcard case.
  • Remove an unused MEDIUM_BUFFER_SIZE re-export (and associated lint suppression) from labels/mod.rs.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/labels/helpers.rs Simplifies permission-to-integrity mapping by removing a redundant match arm while preserving intent via an inline comment.
guards/github-guard/rust-guard/src/labels/mod.rs Removes an unused constant re-export to reduce unused lint suppressions and avoid unnecessary exports.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines 1269 to +1272
match normalized.as_str() {
"admin" | "maintain" | "write" => writer_integrity(scope, ctx),
"triage" | "read" => reader_integrity(scope, ctx),
"none" => vec![],
_ => vec![],
_ => vec![], // "none" or any unrecognised value → no integrity
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

The PR/issue description states the pre-change "none" => vec![] match arm was unreachable due to the wildcard arm below it. In Rust, match arms are evaluated top-to-bottom, so the explicit "none" arm was reachable; it was redundant (same behavior as _), not dead/unreachable. Consider updating the PR description (and/or commit message) to avoid documenting incorrect Rust match semantics.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rust-guard] Rust Guard: Remove redundant match arm and unused re-export

2 participants