-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give a better error message for cargo check
on libstd itself
#76446
Conversation
Previously, the errors looked like this: ``` $ cargo check Checking std v0.0.0 (/home/joshua/rustc/library/std) error: duplicate lang item in crate `core`: `bool`. | = note: the lang item is first defined in crate `core` (which `std` depends on) = note: first definition in `core` loaded from /home/joshua/.local/lib/cargo/target/debug/deps/libcore-afaeeb022194dcf3.rmeta = note: second definition in `core` loaded from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2675a9a46b5cec89.rlib error[E0119]: conflicting implementations of trait `ffi::c_str::CString::new::SpecIntoVec` for type `&str`: --> library/std/src/ffi/c_str.rs:392:9 | 379 | impl<T: Into<Vec<u8>>> SpecIntoVec for T { | ---------------------------------------- first implementation here ... 392 | impl SpecIntoVec for &'_ str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&str` | = note: upstream crates may add a new impl of trait `core::convert::Into<alloc_crate::vec::Vec<u8>>` for type `&str` in future versions error: aborting due to 119 previous errors; 93 warnings emitted ``` Now, they're much more helpful: ``` $ cargo check Compiling core v0.0.0 (/home/joshua/rustc2/library/core) error: failed to run custom build command for `core v0.0.0 (/home/joshua/rustc2/library/core)` Caused by: process didn't exit successfully: `/home/joshua/.local/lib/cargo/target/debug/build/core-ea3b18d34c1ee1c8/build-script-build` (exit code: 101) --- stderr error: you are attempting to build libcore without going through bootstrap help: use `x.py build --stage 0 library/std`, not `cargo build` help: use `x.py check`, not `cargo check` note: if you're sure you want to do this, use `RUSTC_BOOTSTRAP=0` or some other dummy value thread 'main' panicked at 'explicit panic', library/core/build.rs:7:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` The metric here is 'did you set RUSTC_BOOTSTRAP'; if so, it's assumed you know what you're doing and no error is given. It's very unlikely (or at least should be!) that someone will have RUSTC_BOOTSTRAP globally set, so I think this is a good heuristic.
This will break |
I don't know how those work. Do they build with nightly, is that how they allow using nightly features? Is there a way to tell the difference between |
Yes
I think so. Xargo is in maintenance mode, but it is still used by miri. |
Hm instead of repurposing RUSTC_BOOTSTRAP for this, could we add a new variable? FWIW this does just work with "cargo check --manifest-path library/test/Cargo.toml" so maybe we should be suggesting that. build also works, though test currently does not. |
How hard would it be to have cargo do that automatically? Maybe by putting that file in |
I suspect having two workspaces in rust-lang/rust might be a good idea long-term regardless to lessen various other pains, so I wouldn't mind having a dedicated library workspace. That'll take some work, though. |
What is this blocked on? |
This is blocked on either convincing |
Ideally, we could just make |
I'm going to go ahead and close this as I think the things it is blocked on are unlikely to change in the near future -- the general problem is one we'd like to solve, but I doubt it'll happen quickly... |
…haelwoerister Improve error message when `cargo build` is used to build the compiler Inspired by rust-lang#76446. Doing it for `core` is probably higher value but also way harder because tools like cargo or rustc-build-sysroot would need to be fixed first, which I don't feel like doing.
Rollup merge of rust-lang#120475 - Nilstrieb:cargo-build-my-a-, r=michaelwoerister Improve error message when `cargo build` is used to build the compiler Inspired by rust-lang#76446. Doing it for `core` is probably higher value but also way harder because tools like cargo or rustc-build-sysroot would need to be fixed first, which I don't feel like doing.
Previously, the errors looked like this:
Now, they're much more helpful:
The metric here is 'did you set RUSTC_BOOTSTRAP'; if so, it's assumed
you know what you're doing and no error is given. It's very unlikely (or
at least should be!) that someone will have RUSTC_BOOTSTRAP globally
set, so I think this is a good heuristic.
Closes #76444.
r? @Mark-Simulacrum
cc @jix