Skip to content

Commit

Permalink
test(build-std): resolve too less deps
Browse files Browse the repository at this point in the history
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provied through `-Zbuild-std-feature`,
the default feature set `panic-unwind` wouldn't be gone, so
no `panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See #14935
  • Loading branch information
weihanglo committed Dec 17, 2024
1 parent 2e26bfb commit 5ea56fb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,30 @@ fn test_proc_macro() {
"#]])
.run();
}

#[cargo_test(build_std_real)]
fn test_panic_abort() {
// See rust-lang/cargo#14935
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
edition = "2021"
"#,
)
.file("src/lib.rs", "#![no_std]")
.build();

p.cargo("check")
.build_std_arg("std,panic_abort")
.env("RUSTFLAGS", "-C panic=abort")
.arg("-Zbuild-std-features=panic_immediate_abort")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] package ID specification `panic_unwind` did not match any packages
"#]])
.run();
}

0 comments on commit 5ea56fb

Please sign in to comment.