Skip to content

[Repo Assist] fix(rust-guard): replace to_lowercase() with eq_ignore_ascii_case, remove stale dead_code#3325

Merged
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-3314-rust-guard-eq-ignore-ascii-62e70dc160e18c49
Apr 7, 2026
Merged

[Repo Assist] fix(rust-guard): replace to_lowercase() with eq_ignore_ascii_case, remove stale dead_code#3325
lpcox merged 1 commit intomainfrom
repo-assist/fix-issue-3314-rust-guard-eq-ignore-ascii-62e70dc160e18c49

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 7, 2026

🤖 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.rs

Replace to_lowercase() + == in is_trusted_first_party_bot with eq_ignore_ascii_case:

Before: allocates a String on every call via to_lowercase()
After: zero-allocation byte-by-byte in-place comparison — consistent with the existing username_in_list helper (line 248) which already uses eq_ignore_ascii_case

All bot literals are pure ASCII lowercase, so the semantics are identical.

2. guards/github-guard/rust-guard/src/lib.rs

Remove six stale #[allow(dead_code)] attributes from:

  • invoke_backend — public function, referenced in labels/backend.rs
  • LogLevel enum — all variants used by the log helpers
  • log_debug, log_info, log_warn, log_error — called throughout labels/backend.rs and labels/helpers.rs

These 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 the eq_ignore_ascii_case pattern established by username_in_list, and the #[allow(dead_code)] attributes were never cleaned up after the code became active.

Test Status

Rust tests: cargo test — 251 passed, 0 failed
⚠️ 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)

Closes #3314


AI disclosure: This PR was created by Repo Assist, an automated AI assistant.

Generated by Repo Assist · ● 3.2M ·

To install this agentic workflow, run

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

…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>
@lpcox lpcox marked this pull request as ready for review April 7, 2026 18:31
Copilot AI review requested due to automatic review settings April 7, 2026 18:31
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

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 in is_trusted_first_party_bot with eq_ignore_ascii_case to avoid per-call heap allocation.
  • Removed stale #[allow(dead_code)] attributes from invoke_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

@lpcox lpcox merged commit 2d22a6c into main Apr 7, 2026
7 checks passed
@lpcox lpcox deleted the repo-assist/fix-issue-3314-rust-guard-eq-ignore-ascii-62e70dc160e18c49 branch April 7, 2026 18:33
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: Replace heap-allocating to_lowercase() with eq_ignore_ascii_case in is_trusted_first_party_bot

2 participants