You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

rustc_private与build-std兼容问题求助:重复lang item错误

Rust nightly-2023-12-28 编译时出现duplicate lang item错误的问题排查与求助

我在使用Rust nightly-2023-12-28工具链时遇到编译错误:项目中启用了#![feature(rustc_private)]特性,执行以下编译命令:

cargo build --no-default-features -Z build-std=core,std,alloc,proc_macro,test -Z unstable-options --target "x86_64-unknown-linux-gnu" --out-dir target/debug

编译器报出多条error[E0152]: duplicate lang item in crate 'core'错误,比如RangeTo的重复定义问题。

疑问与求助

  • 这是否是已知问题?
  • 由于项目必须依赖该nightly版本且必须使用上述-Z选项,我该如何解决这个错误?
  • 如果不是常见问题,我是否可以将报错信息发布到论坛或在GitHub提交issue?

最小复现代码

main.rs

#![feature(rustc_private)]

extern crate libc;

fn main() {
    println!("Hello, world!");
}

Cargo.toml

[package]
name = "test_libc"
version = "0.1.0"
edition = "2021"

[dependencies]

rust-toolchain.toml

[toolchain]
channel = "nightly-2023-12-28"
components = ["rustfmt", "clippy", "rust-src", "rust-analyzer"]
profile = "minimal"

内容的提问来源于stack exchange,提问作者calvin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 23:34:52