From cbc4589c4c47e9ea1525067c669388971fb2dcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 23 Jun 2019 00:28:33 +0200 Subject: [PATCH 1/2] travis: run cargo fmt on subcrates as well --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 35dd6011943..1eceab89b0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,13 @@ matrix: - rustup component add rustfmt script: - cargo fmt --all -- --check + - cd crates/cargo-test-macro + - cargo fmt --all -- --check + - cd ../crates-io + - cargo fmt --all -- --check + - cd ../resolver-tests + - cargo fmt --all -- --check + - cd ../../ - env: TARGET=x86_64-unknown-linux-gnu ALT=i686-unknown-linux-gnu From 51a56a452d570f2d5484da3f4ca937c143f7bbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 23 Jun 2019 00:29:52 +0200 Subject: [PATCH 2/2] format crates-io and cargo-test-macro subcrates --- crates/cargo-test-macro/src/lib.rs | 6 ++++-- crates/crates-io/lib.rs | 32 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crates/cargo-test-macro/src/lib.rs b/crates/cargo-test-macro/src/lib.rs index 3a4b736bc23..badc3f08233 100644 --- a/crates/cargo-test-macro/src/lib.rs +++ b/crates/cargo-test-macro/src/lib.rs @@ -1,7 +1,7 @@ extern crate proc_macro; use quote::{quote, ToTokens}; -use syn::{*, parse::Parser}; +use syn::{parse::Parser, *}; #[proc_macro_attribute] pub fn cargo_test( @@ -13,7 +13,9 @@ pub fn cargo_test( let attr = quote! { #[test] }; - fn_def.attrs.extend(Attribute::parse_outer.parse2(attr).unwrap()); + fn_def + .attrs + .extend(Attribute::parse_outer.parse2(attr).unwrap()); let stmt = quote! { let _test_guard = crate::support::paths::init_root(); diff --git a/crates/crates-io/lib.rs b/crates/crates-io/lib.rs index 941b0d75a92..913b61f7a6d 100644 --- a/crates/crates-io/lib.rs +++ b/crates/crates-io/lib.rs @@ -185,7 +185,9 @@ impl Registry { (json.len() >> 8) as u8, (json.len() >> 16) as u8, (json.len() >> 24) as u8, - ].iter().cloned(), + ] + .iter() + .cloned(), ); w.extend(json.as_bytes().iter().cloned()); w.extend( @@ -194,7 +196,9 @@ impl Registry { (stat.len() >> 8) as u8, (stat.len() >> 16) as u8, (stat.len() >> 24) as u8, - ].iter().cloned(), + ] + .iter() + .cloned(), ); w }; @@ -337,17 +341,17 @@ impl Registry { Ok(body) => body, Err(..) => bail!("response body was not valid utf-8"), }; - let errors = serde_json::from_str::(&body).ok().map(|s| { - s.errors.into_iter().map(|s| s.detail).collect::>() - }); + let errors = serde_json::from_str::(&body) + .ok() + .map(|s| s.errors.into_iter().map(|s| s.detail).collect::>()); match (self.handle.response_code()?, errors) { - (0, None) | (200, None) => {}, - (503, None) if started.elapsed().as_secs() >= 29 && self.host_is_crates_io() => { - bail!("Request timed out after 30 seconds. If you're trying to \ - upload a crate it may be too large. If the crate is under \ - 10MB in size, you can email help@crates.io for assistance.") - } + (0, None) | (200, None) => {} + (503, None) if started.elapsed().as_secs() >= 29 && self.host_is_crates_io() => bail!( + "Request timed out after 30 seconds. If you're trying to \ + upload a crate it may be too large. If the crate is under \ + 10MB in size, you can email help@crates.io for assistance." + ), (code, Some(errors)) => { let code = StatusCode::from_u16(code as _)?; bail!("api errors (status {}): {}", code, errors.join(", ")) @@ -358,9 +362,9 @@ impl Registry { \t{}\n\ body:\n\ {}", - code, - headers.join("\n\t"), - body, + code, + headers.join("\n\t"), + body, ), }