Skip to content

Commit

Permalink
Merge #663
Browse files Browse the repository at this point in the history
663: change edition to 2021 r=reitermarkus a=Emilgardis

also removes author field as it is not displayed on crates.io anymore.


Co-authored-by: Emil Gardström <[email protected]>
  • Loading branch information
bors[bot] and Emilgardis authored Mar 18, 2022
2 parents e93eb2f + 94f2108 commit a11c252
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Change rust edition to 2021 and bump MSRV for the cross binary to 1.58.1
- #654 - Use color-eyre for error reporting
- #658 - Upgrade dependencies
- #647 - Add `mips64-unknown-linux-muslabi64` and `mips64el-unknown-linux-muslabi64` support
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[package]
authors = ["Jorge Aparicio <[email protected]>", "Markus Reiter <[email protected]>"]
build = "build.rs"
description = "Zero setup cross compilation and cross testing"
documentation = "https://github.com/cross-rs/cross"
Expand All @@ -8,7 +7,7 @@ license = "MIT OR Apache-2.0"
name = "cross"
repository = "https://github.com/cross-rs/cross"
version = "0.2.1"
edition = "2018"
edition = "2021"

[dependencies]
atty = "0.2"
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ impl Environment {
}

fn target_path(target: &Target, key: &str) -> String {
format!("TARGET_{}_{}", target.triple(), key)
format!("TARGET_{target}_{key}")
}

fn build_path(key: &str) -> String {
format!("BUILD_{}", key)
format!("BUILD_{key}")
}

fn get_build_var(&self, key: &str) -> Option<String> {
Expand All @@ -46,7 +46,7 @@ impl Environment {
);
let build_env = if let Some(value) = build_xargo {
Some(value.parse::<bool>().wrap_err_with(|| {
format!("error parsing {} from XARGO environment variable", value)
format!("error parsing {value} from XARGO environment variable")
})?)
} else {
None
Expand Down
19 changes: 8 additions & 11 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ pub fn run(
.args(&["-e", "CARGO_TARGET_DIR=/target"]);

if let Some(username) = id::username().unwrap() {
docker.args(&["-e", &format!("USER={}", username)]);
docker.args(&["-e", &format!("USER={username}")]);
}

if let Ok(value) = env::var("QEMU_STRACE") {
docker.args(&["-e", &format!("QEMU_STRACE={}", value)]);
docker.args(&["-e", &format!("QEMU_STRACE={value}")]);
}

if let Ok(value) = env::var("CROSS_DEBUG") {
docker.args(&["-e", &format!("CROSS_DEBUG={}", value)]);
docker.args(&["-e", &format!("CROSS_DEBUG={value}")]);
}

if let Ok(value) = env::var("DOCKER_OPTS") {
Expand Down Expand Up @@ -222,18 +222,15 @@ pub fn image(config: &Config, target: &Target) -> Result<String> {
return Ok(image);
}

let triple = target.triple();

if !DOCKER_IMAGES.contains(&triple) {
if !DOCKER_IMAGES.contains(&target.triple()) {
bail!(
"`cross` does not provide a Docker image for target {}, \
specify a custom image in `Cross.toml`.",
triple
"`cross` does not provide a Docker image for target {target}, \
specify a custom image in `Cross.toml`."
);
}

let version = env!("CARGO_PKG_VERSION");
Ok(format!("{}/{}:{}", CROSS_IMAGE, triple, version))
Ok(format!("{CROSS_IMAGE}/{target}:{version}"))
}

fn docker_read_mount_paths() -> Result<Vec<MountDetail>> {
Expand Down Expand Up @@ -276,7 +273,7 @@ fn dockerinfo_parse_root_mount_path(info: &serde_json::Value) -> Result<MountDet
destination: PathBuf::from("/"),
})
} else {
eyre::bail!("want driver overlay2, got {}", driver_name)
eyre::bail!("want driver overlay2, got {driver_name}")
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ impl Target {
}
}

impl std::fmt::Display for Target {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.triple())
}
}

impl Target {
fn from(triple: &str, target_list: &TargetList) -> Target {
if target_list.contains(triple) {
Expand Down
6 changes: 3 additions & 3 deletions src/rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn install_toolchain(toolchain: &str, verbose: bool) -> Result<()> {
Command::new("rustup")
.args(&["toolchain", "add", toolchain, "--profile", "minimal"])
.run(verbose)
.wrap_err_with(|| format!("couldn't install toolchain `{}`", toolchain))
.wrap_err_with(|| format!("couldn't install toolchain `{toolchain}`"))
}

pub fn install(target: &Target, toolchain: &str, verbose: bool) -> Result<()> {
Expand All @@ -80,14 +80,14 @@ pub fn install(target: &Target, toolchain: &str, verbose: bool) -> Result<()> {
Command::new("rustup")
.args(&["target", "add", target, "--toolchain", toolchain])
.run(verbose)
.wrap_err_with(|| format!("couldn't install `std` for {}", target))
.wrap_err_with(|| format!("couldn't install `std` for {target}"))
}

pub fn install_component(component: &str, toolchain: &str, verbose: bool) -> Result<()> {
Command::new("rustup")
.args(&["component", "add", component, "--toolchain", toolchain])
.run(verbose)
.wrap_err_with(|| format!("couldn't install the `{}` component", component))
.wrap_err_with(|| format!("couldn't install the `{component}` component"))
}

pub fn component_is_installed(component: &str, toolchain: &str, verbose: bool) -> Result<bool> {
Expand Down

0 comments on commit a11c252

Please sign in to comment.