Skip to content

CMSG_SPACE is no longer a const function #4115

Closed
@asomers

Description

@asomers

CMSG_SPACE is supposed to be a const function. It was, until PR #4105. Now, nix fails to build with the libc-0.2 branch. It fails for both x86_64-unknown-linux-gnu and x86_64-unknown-freebsd. I bisected the regression to verify that it really was #4105.

Steps to reproduce:

$ git clone git@github.com:nix-rust/nix.git
$ cd nix
$ sed -I "" 's!version = "0.2.164"!git = "https://github.com/rust-lang/libc.git", rev = "ae052d3b6a045d58b7ef3187a94de81695e2591e"!' Cargo.toml
$ cargo check --all-features
    Updating crates.io index
    Updating git repository `https://github.com/rust-lang/libc.git`
     Locking 54 packages to latest compatible versions
      Adding sysctl v0.4.6 (available: v0.6.0)
   Compiling autocfg v1.4.0
   Compiling libc v0.2.164 (https://github.com/rust-lang/libc.git?rev=ae052d3b6a045d58b7ef3187a94de81695e2591e#ae052d3b)
   Compiling cfg_aliases v0.2.1
    Checking cfg-if v1.0.0
    Checking pin-utils v0.1.0
    Checking bitflags v2.6.0
   Compiling nix v0.29.0 (/tmp/nix)
   Compiling memoffset v0.9.1
error[E0015]: cannot call non-const fn `CMSG_SPACE` in constant functions
   --> src/sys/socket/mod.rs:652:14
    |
652 |     unsafe { libc::CMSG_SPACE(mem::size_of::<T>() as libc::c_uint) as usize }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

For more information about this error, try `rustc --explain E0015`.
error: could not compile `nix` (lib) due to 1 previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions