Skip to content

Add unistd safe rules#259

Merged
nunoplopes merged 3 commits into
Cpp2Rust:masterfrom
lucic71:unistd
Jul 16, 2026
Merged

Add unistd safe rules#259
nunoplopes merged 3 commits into
Cpp2Rust:masterfrom
lucic71:unistd

Conversation

@lucic71

@lucic71 lucic71 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread libc-dep/Cargo.toml Outdated

[dependencies]
libc = "0.2"
nix = { version = "0.30.1", features = ["socket", "net", "fs", "poll", "time", "user", "dir", "term", "event", "hostname"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this dependency needed here?

Comment thread rules/Cargo.toml Outdated
libcc2rs = { version = "0.1.0", path = "../libcc2rs" }
brotli-sys = "0.3"
rustls-ffi = { version = "0.15.3", default-features = false }
nix = { version = "0.30.1", features = ["socket", "net", "fs", "poll", "time", "user", "dir", "term", "event", "hostname"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the .1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread libcc2rs/Cargo.toml Outdated
[dependencies]
libcc2rs-macros = { path = "../libcc2rs-macros", version = "0.1.0" }
libc = "0.2"
nix = { version = "0.30.1", features = ["socket", "net", "fs", "poll", "time", "user", "dir", "term", "event", "hostname"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant this one is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both libcc2rs and libc-dep depend on libc. Adding nix to libc-dep pulls libc with extra traits. This creates a mismatch between the libc version that libcc2rs uses and the one that libc-dep uses.

To unify the libc versions from libcc2rs and libc-dep, I added nix as a dependency in libcc2rs as well.

Without this, weird errors like the following one appear:

error[E0308]: mismatched types                                                                 
   --> main.rs:40:30                       
    |                                                                                          
 40 |     assert!(((((libc::fileno(libcc2rs::stderr_unsafe())) == (2)) as i32) != 0));
    |                 ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FILE`, found `libc::unix::FILE`
    |                 |
    |                 arguments to this function are incorrect
    |
note: there are multiple different versions of crate `libc` in the dependency graph
   --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.186/src/macros.rs:259:9
    |
259 |           pub enum $i { }
    |           --------------- this is the found type
    |
   ::: /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.186/src/macros.rs:259:9
    |
259 |           pub enum $i { }
    |           ^^^^^^^^^^^^^^^ this is the expected type
    |
   ::: /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.186/src/unix/mod.rs:596:1
    |
596 | / extern_ty! {
597 | |     pub enum FILE {}
598 | | }
    | |_- in this macro invocation
    = help: you can use `cargo tree` to explore your dependency tree

@nunoplopes nunoplopes merged commit adab7fe into Cpp2Rust:master Jul 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants