Open
Description
Summary
Clippy panics with a "byte index is not a char boundary" error when running on Rust code generated from .proto
files that contain Chinese (UTF-8) comments. The panic occurs during linting, making it impossible to use clippy on projects with such generated code. Removing the Chinese comments resolves the issue.
Reproducer
To Reproduce Steps to reproduce the behavior:
- Create a .proto file with Chinese comments, e.g.:
// 发送启动信号
rpc SendStartSignal(StartSignalRequest) returns (StartSignalResponse);
- Use
tonic_build
orprost_build
to generate Rust code from the proto. - Run cargo clippy on the project.
Expected behavior Clippy should not panic, even if the generated Rust code contains UTF-8 doc comments.
Actual behavior Clippy panics with:
thread 'rustc' panicked at compiler/rustc_resolve/src/rustdoc.rs:573:52:
byte index X is not a char boundary; it is inside '发' (bytes Y..Z) of `/// 发送启动信号`
Version
clippy version: (e.g. clippy 0.1.89 (45f256d9d 2025-05-27))
rustc version: (e.g. rustc 1.89.0-nightly (45f256d9d 2025-05-27))
OS: macOS (Apple Silicon)
Additional Labels
Removing the Chinese comments from the proto file or disabling doc generation avoids the panic.
This only happens with non-ASCII (e.g. Chinese) comments.