diff --git a/CHANGELOG.md b/CHANGELOG.md index 19452614e..cf94b5c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.toml b/Cargo.toml index a312f7c51..d78bc348b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [package] -authors = ["Jorge Aparicio ", "Markus Reiter "] build = "build.rs" description = "Zero setup cross compilation and cross testing" documentation = "https://github.com/cross-rs/cross" @@ -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" diff --git a/src/config.rs b/src/config.rs index 4d5232007..3c5a37fb5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 { @@ -46,7 +46,7 @@ impl Environment { ); let build_env = if let Some(value) = build_xargo { Some(value.parse::().wrap_err_with(|| { - format!("error parsing {} from XARGO environment variable", value) + format!("error parsing {value} from XARGO environment variable") })?) } else { None diff --git a/src/docker.rs b/src/docker.rs index 718920d5b..bad466e61 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -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") { @@ -222,18 +222,15 @@ pub fn image(config: &Config, target: &Target) -> Result { 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> { @@ -276,7 +273,7 @@ fn dockerinfo_parse_root_mount_path(info: &serde_json::Value) -> Result) -> std::fmt::Result { + f.write_str(self.triple()) + } +} + impl Target { fn from(triple: &str, target_list: &TargetList) -> Target { if target_list.contains(triple) { diff --git a/src/rustup.rs b/src/rustup.rs index 4dd963192..aecd5e14d 100644 --- a/src/rustup.rs +++ b/src/rustup.rs @@ -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<()> { @@ -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 {