Skip to content

Zerocopy 0.8.32 breaks combined with deny(non_ascii_idents) #2880

@kristof-mattei

Description

@kristof-mattei

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:

#![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:

❯ 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: 002b97d#diff-977c29e6cf079bd7307f811df24f99633df603962785c583145eb6250b0e12daR755

There was a comment about it: #2842 (comment) but no mention of non_ascii_idents.

Could an allow be applied to those lines, just like here: 002b97d#diff-977c29e6cf079bd7307f811df24f99633df603962785c583145eb6250b0e12daR782 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions