Conversation
…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>
Contributor
There was a problem hiding this comment.
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_floorby collapsing a redundant"none"match arm into the wildcard case. - Remove an unused
MEDIUM_BUFFER_SIZEre-export (and associated lint suppression) fromlabels/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 |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.
Closes #3691
Root Cause
Two pieces of dead code identified in the Rust guard:
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.MEDIUM_BUFFER_SIZEre-export (labels/mod.rs): This constant was re-exported speculatively "for backward compatibility" but is never consumed externally —backend.rsalready imports it directly fromsuper::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 integrityto preserve the documented intent.labels/mod.rs: Remove theMEDIUM_BUFFER_SIZEpub useand its#[allow(unused_imports)]annotation (3 lines removed).Behaviour
No behaviour change. The
"none"permission value continues to returnvec![], the same result as before. All existing tests (includingtest_collaborator_permission_floor_none) pass unchanged.Test Status
Go build skipped (Go 1.25.0 toolchain not locally available in CI environment — infrastructure limitation unrelated to these Rust-only changes).