Skip to content

Commit

Permalink
Merge pull request #16 from epage/ignore-rust-toolchain-files
Browse files Browse the repository at this point in the history
Always specify cargo toolchain
  • Loading branch information
epage authored Apr 22, 2022
2 parents 8b6f3d1 + 1229d22 commit 2c151bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
# Run twice to test problem with expression caching
./tests/scripts/test-runner.sh
./tests/scripts/test-runner.sh
(cd tests/scripts/ignores-rust-toolchain && ../../../target/debug/rust-script test.rs)
check-format:
runs-on: ubuntu-latest
Expand Down
15 changes: 7 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ struct Args {
build_kind: BuildKind,
template: Option<String>,
list_templates: bool,
// This is a String instead of an
// enum since one can have custom
// toolchains (ex. a rustc developer
// will probably have `stage1`).
// This is a String instead of an enum since one can have custom
// toolchains (ex. a rustc developer will probably have `stage1`):
toolchain_version: Option<String>,

#[cfg(windows)]
Expand Down Expand Up @@ -1153,15 +1151,16 @@ Constructs a Cargo command that runs on the script package.
fn cargo(
cmd_name: &str,
manifest: &str,
maybe_toolchain_version: Option<&str>,
toolchain_version: Option<&str>,
meta: &PackageMetadata,
script_args: &[String],
run_quietly: bool,
) -> MainResult<Command> {
let mut cmd = Command::new("cargo");
if let Some(toolchain_version) = maybe_toolchain_version {
cmd.arg(format!("+{}", toolchain_version));
}

// Always specify a toolchain to avoid being affected by rust-version(.toml) files:
cmd.arg(format!("+{}", toolchain_version.unwrap_or("stable")));

cmd.arg(cmd_name);

if cmd_name == "run" && run_quietly {
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/ignores-rust-toolchain/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid-rust-version
1 change: 1 addition & 0 deletions tests/scripts/ignores-rust-toolchain/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std::process::exit(0);

0 comments on commit 2c151bc

Please sign in to comment.