Skip to content

Regression: E0761 module conflict in std::sys::net breaks Apple target builds with -Z build-std #146612

@alycda

Description

@alycda

Code

I tried this code:

cargo +nightly build --target aarch64-apple-tvos -Z build-std=std,panic_abort

Expected vs Actual Behavior

I expected to see this happen: The build should succeed as it did with previous nightly versions

Instead, this happened: Build fails with E0761 module conflict in Rust standard library

error[E0761]: file for module \`socket\` found at both "/Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/connection/socket.rs" and "/Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/connection/socket/mod.rs"
 --> /Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/mod.rs:10:13
  |
10 |            mod socket;
   |             ^^^^^^^^^^^
   |
   = help: delete or rename one of them to remove the ambiguity

error[E0432]: unresolved import \`crate::sys::net::LookupHost\`
error[E0432]: unresolved import \`crate::sys::net::Socket\`
error[E0412]: cannot find type \`TcpStream\` in module \`net_imp\`
error[E0412]: cannot find type \`TcpListener\` in module \`net_imp\`

Version it worked on

rustc 1.91.0-nightly (5eda692e7 2025-09-11)
binary: rustc
commit-hash: 5eda692e73f37dcbe2437ce878db7bb71f323e74
commit-date: 2025-09-11
host: aarch64-apple-darwin
release: 1.91.0-nightly
LLVM version: 21.1.1

Version with regression

rustc 1.92.0-nightly (52618eb33 2025-09-14)
binary: rustc
commit-hash: 52618eb338609df44978b0ca451ab7941fd1c7a
commit-date: 2025-09-14
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.1

Additional Information

This affects all Apple targets when using `-Z build-std`:

  • aarch64-apple-tvos
  • aarch64-apple-ios
  • aarch64-apple-ios-sim
  • x86_64-apple-ios
  • aarch64-apple-visionos
  • aarch64-apple-visionos-sim

The issue appears to be a module conflict in the standard library where both `socket.rs` and `socket/mod.rs` exist in the same directory, causing E0761. This breaks Apple target compilation when using build-std feature.

Workaround: Use `nightly-2025-09-12` or earlier.

Impact: Prevents building any Apple targets with -Z build-std, breaking CI/CD pipelines and development workflows.

Backtrace

From GitHub Actions log:

error[E0761]: file for module \`socket\` found at both "/Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/connection/socket.rs" and "/Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/connection/socket/mod.rs"
 --> /Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/net/mod.rs:10:13
  |
10 |            mod socket;
   |             ^^^^^^^^^^^
   |
   = help: delete or rename one of them to remove the ambiguity

error[E0432]: unresolved import \`crate::sys::net::LookupHost\`
 --> /Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/net/socket_addr.rs:9:5
  |
9 | use crate::sys::net::LookupHost;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no \`LookupHost\` in \`sys::net\`

error[E0432]: unresolved import \`crate::sys::net::Socket\`
 --> /Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/os/unix/net/datagram.rs:26:5
  |
26 | use crate::sys::net::Socket;
   |     ^^^^^^^^^^^^^^^^^^^^^^^ no \`Socket\` in \`sys::net\`

error[E0412]: cannot find type \`TcpStream\` in module \`net_imp\`
 --> /Users/runner/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/net/tcp.rs:63:31
  |
63 | pub struct TcpStream(net_imp::TcpStream);
   |                               ^^^^^^^^^ not found in \`net_imp\`

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable cargo option: -Zbuild-stdO-appleOperating system: Apple (macOS, iOS, tvOS, visionOS, watchOS)T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions