mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Fix panic with -Zbuild-std and no roots.
This commit is contained in:
parent
5c40b7f6dc
commit
6b472c90e1
@ -62,6 +62,12 @@ pub fn build_unit_dependencies<'a, 'cfg>(
|
||||
profiles: &'a Profiles,
|
||||
interner: &'a UnitInterner,
|
||||
) -> CargoResult<UnitGraph> {
|
||||
if roots.is_empty() {
|
||||
// If -Zbuild-std, don't attach units if there is nothing to build.
|
||||
// Otherwise, other parts of the code may be confused by seeing units
|
||||
// in the dep graph without a root.
|
||||
return Ok(HashMap::new());
|
||||
}
|
||||
let (std_resolve, std_features) = match std_resolve {
|
||||
Some((r, f)) => (Some(r), Some(f)),
|
||||
None => (None, None),
|
||||
|
@ -677,3 +677,23 @@ fn different_features() {
|
||||
.target_host()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn no_roots() {
|
||||
// Checks for a bug where it would panic if there are no roots.
|
||||
let setup = match setup() {
|
||||
Some(s) => s,
|
||||
None => return,
|
||||
};
|
||||
let p = project().file("tests/t1.rs", "").build();
|
||||
p.cargo("build")
|
||||
.build_std(&setup)
|
||||
.target_host()
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user