From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: rust: update `kernel::c_str!` documentation
Date: Tue, 10 Mar 2026 12:05:04 +1000 [thread overview]
Message-ID: <review-patch1-20260309-cstr-rename-macro-v2-1-25f7de75944e@kernel.org> (raw)
In-Reply-To: <20260309-cstr-rename-macro-v2-1-25f7de75944e@kernel.org>
Patch Review
**Summary:** Updates the doc comment on `c_str!` to explain that `c"literal"` syntax should be preferred for string literals, and that `c_str!` remains useful for non-literal compile-time strings (e.g. `concat!(file!(), ...)`). Also adds a comment explaining why a `compile_error!` arm for literal arguments was intentionally omitted.
**Positive observations:**
1. The updated doc comment at line 379-383 is clear and well-written, correctly explaining the relationship between `c"..."` literals and the macro.
2. The new "Panics" section (lines 385-387) documenting the interior NUL panic behavior is a good addition — the old documentation only said "should not contain any `NUL` bytes" without specifying what happens.
3. The example is well-chosen:
```rust
// This is allowed, but `c"literal"` should be preferred for literals.
const BAD: &CStr = c_str!("literal");
// `c_str!` is still needed for static non-literal C strings.
const GOOD: &CStr = c_str!(concat!(file!(), ":", line!(), ": My CStr!"));
```
Naming the first example `BAD` and the second `GOOD` makes the intent immediately obvious.
4. The NB comment at lines 402-404 explaining the design decision not to add a `compile_error!` arm for `$str:lit` is valuable — it preempts the natural follow-up question of "why not just reject literals?" and explains that it would break macro authors who happen to have a literal at the top of expansions.
**Minor observations:**
- The "Panics" section says the macro "panics" — technically it's a compile-time `panic!` (since it's used in a `const` context), which is a compilation error, not a runtime panic. This is arguably a pedantic distinction and the current wording matches Rust documentation conventions, so it's fine as-is.
**Verdict:** Looks good. No issues found.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-10 2:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 17:01 [PATCH v2] rust: update `kernel::c_str!` documentation Tamir Duberstein
2026-03-10 2:05 ` Claude Code Review Bot [this message]
2026-03-10 2:05 ` Claude review: " Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=review-patch1-20260309-cstr-rename-macro-v2-1-25f7de75944e@kernel.org \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox