Skip to content

Commit

Permalink
keep support for old rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 5, 2023
1 parent c2e2a01 commit 411030a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl SysrootBuilder {
)
.context("failed to copy lockfile from sysroot source")?;
make_writeable(&lock_file).context("failed to make lockfile writeable")?;
let have_sysroot_crate = src_dir.join("sysroot").exists();
let crates = match &self.config {
SysrootConfig::NoStd => format!(
r#"
Expand All @@ -262,7 +263,7 @@ version = "*"
src_dir_core = src_dir.join("core"),
src_dir_alloc = src_dir.join("alloc"),
),
SysrootConfig::WithStd { std_features } => format!(
SysrootConfig::WithStd { std_features } if have_sysroot_crate => format!(
r#"
[dependencies.std]
features = {std_features:?}
Expand All @@ -274,6 +275,19 @@ path = {src_dir_sysroot:?}
src_dir_std = src_dir.join("std"),
src_dir_sysroot = src_dir.join("sysroot"),
),
// Fallback for old rustc where the main crate was `test`, not `sysroot`
SysrootConfig::WithStd { std_features } => format!(
r#"
[dependencies.std]
features = {std_features:?}
path = {src_dir_std:?}
[dependencies.test]
path = {src_dir_test:?}
"#,
std_features = std_features,
src_dir_std = src_dir.join("std"),
src_dir_test = src_dir.join("test"),
),
};
let manifest = format!(
r#"
Expand Down

0 comments on commit 411030a

Please sign in to comment.