Skip to content

Commit 4a976bf

Browse files
committed
test(build-std): resolve too less deps
This failed because since 125e873 [`std_resolve`][1] only includes `sysroot` as primary package. When any custom Cargo feature is provided via `-Zbuild-std-feature`, the default feature set `panic-unwind` would 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
1 parent 6672adb commit 4a976bf

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/build-std/main.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,30 @@ fn test_proc_macro() {
418418
"#]])
419419
.run();
420420
}
421+
422+
#[cargo_test(build_std_real)]
423+
fn test_panic_abort() {
424+
// See rust-lang/cargo#14935
425+
let p = project()
426+
.file(
427+
"Cargo.toml",
428+
r#"
429+
[package]
430+
name = "foo"
431+
edition = "2021"
432+
"#,
433+
)
434+
.file("src/lib.rs", "#![no_std]")
435+
.build();
436+
437+
p.cargo("check")
438+
.build_std_arg("std,panic_abort")
439+
.env("RUSTFLAGS", "-C panic=abort")
440+
.arg("-Zbuild-std-features=panic_immediate_abort")
441+
.with_status(101)
442+
.with_stderr_data(str![[r#"
443+
[ERROR] package ID specification `panic_unwind` did not match any packages
444+
445+
"#]])
446+
.run();
447+
}

0 commit comments

Comments
 (0)