google / google/zerocopy

Zerocopy 0.8.32 breaks combined with `deny(non_ascii_idents)`

Open
#2,880 5 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
179
Avg merge
1d 19h
Merged PRs (30d)
29

Description

For security reasons we cannot allow `non-ascii-identifiers` in our codebase, and as such we apply `#![deny(non_ascii_idents)]`.

However, since upgrading to Zerocopy 0.8.32 (0.8.33 has same behavior) we are running into violations of the `non_ascii_idents` lint.

`src/main.rs`:

```rust
#![deny(non_ascii_idents)]

use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};

#[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
#[repr(C)]
pub struct ifaddrmsg {
pub ifa_family: u8, /* Address type */
pub ifa_prefixlen: u8, /* Prefixlength of address */
pub ifa_flags: u8, /* Address flags */
pub ifa_scope: u8, /* Address scope */
pub ifa_index: u32, /* Interface index */
}

fn main() {}
```

Cargo.toml:
```
[package]
name = "zerocopy-non-ascii-error"
version = "0.1.0"
edition = "2024"

[dependencies]
zerocopy = { version = "0.8.33", features = ["derive"] }
```

`bash`:

```bash
❯ cargo run
Compiling zerocopy-non-ascii-error v0.1.0 (/home/kristof/projects/zerocopy-non-ascii-error)
error: identifier contains non-ASCII characters
--> src/main.rs:8:9
|
8 | pub ifa_family: u8, /* Address type */
| ^^^^^^^^^^
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(non_ascii_idents)]
| ^^^^^^^^^^^^^^^^

error: identifier contains non-ASCII characters
--> src/main.rs:9:9
|
9 | pub ifa_prefixlen: u8, /* Prefixlength of address */
| ^^^^^^^^^^^^^

error: identifier contains non-ASCII characters
--> src/main.rs:10:9
|
10 | pub ifa_flags: u8, /* Address flags */
| ^^^^^^^^^

error: identifier contains non-ASCII characters
--> src/main.rs:11:9
|
11 | pub ifa_scope: u8, /* Address scope */
| ^^^^^^^^^

error: identifier contains non-ASCII characters
--> src/main.rs:12:9
|
12 | pub ifa_index: u32, /* Interface index */
| ^^^^^^^^^

error: could not compile `zerocopy-non-ascii-error` (bin "zerocopy-non-ascii-error") due to 5 previous errors
```

Traced back to this PR: https://github.com/google/zerocopy/commit/002b97de9b73c1d012ae8241780931e717965219#diff-977c29e6cf079bd7307f811df24f99633df603962785c583145eb6250b0e12daR755

There was a comment about it: https://github.com/google/zerocopy/pull/2842#discussion_r2590153675 but no mention of `non_ascii_idents`.

Could an allow be applied to those lines, just like here: https://github.com/google/zerocopy/commit/002b97de9b73c1d012ae8241780931e717965219#diff-977c29e6cf079bd7307f811df24f99633df603962785c583145eb6250b0e12daR782 ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.