Skip to content

Regression in nightly-2026-05-04: rustix crate fails to build: attributes starting with rustc are reserved for use by the rustc compiler #156510

Description

@anforowicz

Code

I tried this code:

$ cat Cargo.toml
[package]
name = "repro-2026-05-12"
version = "0.1.0"
edition = "2024"

[dependencies]
rustix="=0.37.28"

lukasza2 in /usr/local/google/home/lukasza/src/cargo/repro-2026-05-12
$ cat src/main.rs
fn main() {}

I expected to see this happen: This code should build fine.

Instead, this happened: This code fails to build with a recent nightly:

$ rustc --version
rustc 1.97.0-nightly (64a965e90 2026-05-11)

$ cargo build
   Compiling rustix v0.37.28
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
  --> /usr/local/google/home/lukasza/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.37.28/src/backend/linux_raw/io/errno.rs:28:25
   |
28 | #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0xf001))]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
  --> /usr/local/google/home/lukasza/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.37.28/src/backend/linux_raw/io/errno.rs:29:25
   |
29 | #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_end(0xffff))]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_layout_scalar_valid_range_start` in this scope
  --> /usr/local/google/home/lukasza/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.37.28/src/backend/linux_raw/io/errno.rs:28:25
   |
28 | #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0xf001))]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_layout_scalar_valid_range_end` in this scope
  --> /usr/local/google/home/lukasza/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.37.28/src/backend/linux_raw/io/errno.rs:29:25
   |
29 | #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_end(0xffff))]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `rustix` (lib) due to 4 previous errors

Version it worked on

cargo bisect-rustc says:

Regression in 684d04c. Note that if it is a legacy rollup build, it might be available in rust-lang-ci@684d04c.

The PR introducing the regression in this rollup is #155433: Rip out rustc_layout_scalar_valid_range_* attribute support

searched nightlies: from nightly-2026-04-27 to nightly-2026-05-12
regressed nightly: nightly-2026-05-04
searched commit range: 20de910...ad3a598
regressed commit: 818811b

bisected with cargo-bisect-rustc v0.6.11

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc

Original bug

The original repro was using cargo to build bindgen in https://crbug.com/510018493. I guess the rustix-based repro can probably be reduced further, but hopefully this is enough to help start the investigation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions