Skip to content

refactor: remove unsafe for static strings - #30867

Merged
dylan-conway merged 3 commits into
oven-sh:mainfrom
robjtede:less-unsafe-npm-name
May 17, 2026
Merged

dylan-conway merged 3 commits into
oven-sh:mainfrom
robjtede:less-unsafe-npm-name

Conversation

@robjtede

@robjtede robjtede commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes unnecessary str::from_utf8_unchecks calls for static slices.

How did you verify your code works?

Trivial conversion.

@robjtede
robjtede marked this pull request as ready for review May 16, 2026 00:18

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai

coderabbitai Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b42c464c-b546-4069-b748-11bf10827bc0

📥 Commits

Reviewing files that changed from the base of the PR and between c2fae96 and 41231dd.

📒 Files selected for processing (1)
  • src/bun_core/env.rs

Walkthrough

Architecture::npm_name and Libc::npm_name are converted from non-const methods returning byte slices (&'static [u8]) to const fn returning UTF-8 string slices (&'static str). Call sites in URL generation and Display implementations are updated to use .as_bytes() or write the strings directly.

Changes

npm_name const string return

Layer / File(s) Summary
Architecture::npm_name const string return
src/bun_core/env.rs
Architecture::npm_name is made a const fn returning &'static str with string literals ("...") instead of &'static [u8] with byte literals (b"...").
Libc::npm_name const string return and Display
src/options_types/compile_target.rs
Libc::npm_name is converted to a const fn returning &'static str, and fmt::Display for Libc is updated to write the string directly instead of converting from bytes.
CompileTarget call site updates
src/options_types/compile_target.rs
npm registry URL construction calls as_bytes() on the new string-based arch and libc names, and fmt::Display for CompileTarget writes arch.npm_name() directly instead of wrapping it as bytes.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring objective of removing unsafe operations for static strings across the codebase.
Description check ✅ Passed The description covers both required template sections with clear explanations of what the PR does and how it was verified.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dylan-conway dylan-conway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@dylan-conway
dylan-conway merged commit 112f305 into oven-sh:main May 17, 2026
73 of 75 checks passed
@robjtede
robjtede deleted the less-unsafe-npm-name branch May 17, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants