From 785cbf62bb4a4245183365b1df29a0dd41602a24 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 21 Jun 2022 10:02:17 +0200 Subject: [PATCH 1/2] Fix: The `alloc` crate uses the Rust 2021 edition now The alloc library was switched to the 2021 edition in . However, it did not use any features of the new edition until PR , which relies on the newer closure capture mechanism. This commit fixes the build on the latest nightlies, which include that PR. Fixes #104 --- src/sysroot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sysroot.rs b/src/sysroot.rs index 5d1d940..6735027 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -177,7 +177,7 @@ fn build_liballoc( authors = ["The Rust Project Developers"] name = "alloc" version = "0.0.0" -edition = "2018" +edition = "2021" [dependencies.compiler_builtins] version = "0.1.0" From 3a70441cef0793d1ee8990936961559c5b2f749e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 21 Jun 2022 10:02:48 +0200 Subject: [PATCH 2/2] Run cargo fmt --- src/cargo.rs | 3 ++- src/flock.rs | 15 ++++++++------- src/rustc.rs | 6 ++++-- src/sysroot.rs | 19 +++++++++---------- src/util.rs | 2 +- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/cargo.rs b/src/cargo.rs index 64449ae..ef38cf8 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -123,7 +123,8 @@ fn flags(config: Option<&Config>, target: &str, tool: &str) -> Result Filesystem { - Filesystem { path: path, quiet: quiet } + Filesystem { + path: path, + quiet: quiet, + } } pub fn join(&self, other: T) -> Filesystem @@ -111,7 +114,9 @@ impl Filesystem { })?; } State::Shared => { - acquire(msg, &path, self.quiet, &|| try_lock_shared(&f), &|| lock_shared(&f))?; + acquire(msg, &path, self.quiet, &|| try_lock_shared(&f), &|| { + lock_shared(&f) + })?; } } @@ -183,11 +188,7 @@ fn acquire( } if !quiet { - eprintln!( - "{:>12} waiting for file lock on {}", - "Blocking", - msg - ) + eprintln!("{:>12} waiting for file lock on {}", "Blocking", msg) } lock_block() diff --git a/src/rustc.rs b/src/rustc.rs index 887a311..207052d 100644 --- a/src/rustc.rs +++ b/src/rustc.rs @@ -73,8 +73,10 @@ impl Sysroot { }); } - Err(anyhow!("`rust-src` component not found. Run `rustup component add \ - rust-src`.")) + Err(anyhow!( + "`rust-src` component not found. Run `rustup component add \ + rust-src`." + )) } } diff --git a/src/sysroot.rs b/src/sysroot.rs index 6735027..312c39e 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -93,12 +93,14 @@ fn build_crate( td_lockfile.display() ) })?; - let mut perms = fs::metadata(&td_lockfile).with_context(|| { - format!( - "failed to retrieve permissions for `{}`", - td_lockfile.display() - ) - })?.permissions(); + let mut perms = fs::metadata(&td_lockfile) + .with_context(|| { + format!( + "failed to retrieve permissions for `{}`", + td_lockfile.display() + ) + })? + .permissions(); perms.set_readonly(false); fs::set_permissions(&td_lockfile, perms).with_context(|| { format!( @@ -192,10 +194,7 @@ version = "0.1.0" } stoml.push_str("[dependencies.core]\n"); - stoml.push_str(&format!( - "path = '{}'\n", - src.path().join("core").display() - )); + stoml.push_str(&format!("path = '{}'\n", src.path().join("core").display())); if config.panic_immediate_abort { stoml.push_str("features = ['panic_immediate_abort']\n"); diff --git a/src/util.rs b/src/util.rs index baedda0..7dfb8f2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::Path; -use anyhow::{anyhow, Result, Context}; +use anyhow::{anyhow, Context, Result}; use toml::Value; use walkdir::WalkDir;