Conversation
…move stale dead_code - Replace heap-allocating to_lowercase() + == in is_trusted_first_party_bot with zero-allocation eq_ignore_ascii_case, consistent with username_in_list - Remove six stale #[allow(dead_code)] attributes from lib.rs (invoke_backend, LogLevel, log_debug, log_info, log_warn, log_error are all actively used) Closes #3314 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes a small performance-oriented improvement in the Rust GitHub guard by switching a hot-path bot username check to a zero-allocation ASCII case-insensitive comparison, and it cleans up stale #[allow(dead_code)] annotations so future unused-code regressions are surfaced by the compiler.
Changes:
- Replaced
to_lowercase()-based comparisons inis_trusted_first_party_botwitheq_ignore_ascii_caseto avoid per-call heap allocation. - Removed stale
#[allow(dead_code)]attributes frominvoke_backend,LogLevel, and internal log helpers.
Show a summary per file
| File | Description |
|---|---|
guards/github-guard/rust-guard/src/labels/helpers.rs |
Updates trusted-bot username matching to use allocation-free ASCII case-insensitive comparisons. |
guards/github-guard/rust-guard/src/lib.rs |
Removes unnecessary dead_code suppression from live logging/backend helper APIs. |
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: 0
This was referenced Apr 7, 2026
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.
Addresses the two improvements described in #3314.
Changes
1.
guards/github-guard/rust-guard/src/labels/helpers.rsReplace
to_lowercase()+==inis_trusted_first_party_botwitheq_ignore_ascii_case:Before: allocates a
Stringon every call viato_lowercase()After: zero-allocation byte-by-byte in-place comparison — consistent with the existing
username_in_listhelper (line 248) which already useseq_ignore_ascii_caseAll bot literals are pure ASCII lowercase, so the semantics are identical.
2.
guards/github-guard/rust-guard/src/lib.rsRemove six stale
#[allow(dead_code)]attributes from:invoke_backend— public function, referenced inlabels/backend.rsLogLevelenum — all variants used by the log helperslog_debug,log_info,log_warn,log_error— called throughoutlabels/backend.rsandlabels/helpers.rsThese attributes were added during early development when the items were conditionally-dead, but the code has since grown and they're all actively used. Keeping them muffles any future dead_code warnings if a refactor accidentally removes a call site.
Root Cause
Both issues were legacy artefacts:
to_lowercase()predates theeq_ignore_ascii_casepattern established byusername_in_list, and the#[allow(dead_code)]attributes were never cleaned up after the code became active.Test Status
✅ Rust tests:
⚠️ Go tests: Infrastructure issue — Go 1.25.0 required but unavailable in CI environment (network-restricted); this is not caused by these changes (Rust-only files modified)
cargo test— 251 passed, 0 failedCloses #3314
AI disclosure: This PR was created by Repo Assist, an automated AI assistant.