Skip to content

Commit 5fc27e2

Browse files
committed
Update to rust 1.26, and explicitly use Itertools::flatten to avoid rust-lang/rust#48919. Additionally, apply rustfmt changes.
1 parent bbbd37a commit 5fc27e2

File tree

13 files changed

+68
-71
lines changed

13 files changed

+68
-71
lines changed

build-support/bin/native/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ esac
4545
readonly CACHE_ROOT=${XDG_CACHE_HOME:-$HOME/.cache}/pants
4646
readonly NATIVE_ENGINE_CACHE_DIR=${CACHE_ROOT}/bin/native-engine
4747

48-
readonly RUST_TOOLCHAIN="1.25.0"
48+
readonly RUST_TOOLCHAIN="1.26.0"
4949

5050
function calculate_current_hash() {
5151
# Cached and unstaged files, with ignored files excluded.

src/rust/engine/boxfuture/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ where
3030
///
3131
#[macro_export]
3232
macro_rules! try_future {
33-
( $x:expr) => {
34-
{
35-
match $x {
36-
Ok(value) => {value}
37-
Err(error) => {return future::err(error).to_boxed();}
38-
}
33+
($x:expr) => {{
34+
match $x {
35+
Ok(value) => value,
36+
Err(error) => {
37+
return future::err(error).to_boxed();
38+
}
3939
}
40-
};
40+
}};
4141
}

src/rust/engine/fs/brfs/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,13 @@ mod test {
643643
extern crate tempdir;
644644
extern crate testutil;
645645

646+
use self::tempdir::TempDir;
647+
use self::testutil::{file, data::{TestData, TestDirectory}};
648+
use super::mount;
646649
use fs;
647650
use futures::future::Future;
648651
use hashing;
649-
use self::tempdir::TempDir;
650652
use std::sync::Arc;
651-
use super::mount;
652-
use self::testutil::{file, data::{TestData, TestDirectory}};
653653

654654
#[test]
655655
fn missing_digest() {
@@ -888,16 +888,16 @@ mod syscall_tests {
888888
extern crate tempdir;
889889
extern crate testutil;
890890

891+
use self::tempdir::TempDir;
892+
use self::testutil::data::TestData;
893+
use super::mount;
894+
use super::test::digest_to_filepath;
891895
use fs;
892896
use futures::Future;
893897
use libc;
894-
use std::sync::Arc;
895-
use super::mount;
896-
use super::test::digest_to_filepath;
897-
use self::tempdir::TempDir;
898-
use self::testutil::data::TestData;
899898
use std::ffi::CString;
900899
use std::path::Path;
900+
use std::sync::Arc;
901901

902902
#[test]
903903
fn read_file_by_digest_exact_bytes() {

src/rust/engine/fs/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ extern crate tempdir;
3737
#[cfg(test)]
3838
extern crate testutil;
3939

40+
use std::cmp::min;
4041
use std::collections::HashSet;
42+
use std::io::{self, Read};
4143
use std::os::unix::fs::PermissionsExt;
4244
use std::path::{Component, Path, PathBuf};
4345
use std::sync::Arc;
4446
use std::{fmt, fs};
45-
use std::io::{self, Read};
46-
use std::cmp::min;
4747

4848
use bytes::Bytes;
4949
use futures::future::{self, Future};
@@ -123,12 +123,9 @@ impl PathStat {
123123

124124
lazy_static! {
125125
static ref PARENT_DIR: &'static str = "..";
126-
127126
static ref SINGLE_STAR_GLOB: Pattern = Pattern::new("*").unwrap();
128-
129127
static ref DOUBLE_STAR: &'static str = "**";
130128
static ref DOUBLE_STAR_GLOB: Pattern = Pattern::new("**").unwrap();
131-
132129
static ref EMPTY_IGNORE: Arc<Gitignore> = Arc::new(Gitignore::empty());
133130
}
134131

@@ -852,9 +849,9 @@ mod posixfs_test {
852849
extern crate tempdir;
853850
extern crate testutil;
854851

852+
use self::testutil::make_file;
855853
use super::{Dir, File, Link, PathStat, PathStatGetter, PosixFS, ResettablePool, Stat};
856854
use futures::Future;
857-
use self::testutil::make_file;
858855
use std;
859856
use std::path::{Path, PathBuf};
860857
use std::sync::Arc;

src/rust/engine/fs/src/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use std::sync::RwLock;
55

6-
use futures_cpupool::{self, CpuFuture, CpuPool};
76
use futures::future::IntoFuture;
7+
use futures_cpupool::{self, CpuFuture, CpuPool};
88

99
///
1010
/// A wrapper around a CpuPool, to add the ability to drop the pool before forking,

src/rust/engine/fs/src/snapshot.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use futures::future::{self, join_all};
1010
use hashing::{Digest, Fingerprint};
1111
use indexmap::{self, IndexMap};
1212
use itertools::Itertools;
13-
use {File, PathStat, PosixFS, Store};
1413
use protobuf;
1514
use std::ffi::OsString;
1615
use std::fmt;
1716
use std::path::PathBuf;
1817
use std::sync::Arc;
18+
use {File, PathStat, PosixFS, Store};
1919

2020
pub const EMPTY_FINGERPRINT: Fingerprint = Fingerprint([
2121
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24,
@@ -152,11 +152,7 @@ impl Snapshot {
152152
// `Directory` structure. Only `Dir+Dir` collisions are legal.
153153
let path_stats = {
154154
let mut uniq_paths: IndexMap<PathBuf, PathStat> = IndexMap::new();
155-
for path_stat in snapshots
156-
.iter()
157-
.map(|s| s.path_stats.iter().cloned())
158-
.flatten()
159-
{
155+
for path_stat in Itertools::flatten(snapshots.iter().map(|s| s.path_stats.iter().cloned())) {
160156
match uniq_paths.entry(path_stat.path().to_owned()) {
161157
indexmap::map::Entry::Occupied(e) => match (&path_stat, e.get()) {
162158
(&PathStat::Dir { .. }, &PathStat::Dir { .. }) => (),
@@ -212,11 +208,11 @@ impl Snapshot {
212208

213209
// Merge FileNodes.
214210
out_dir.set_files(protobuf::RepeatedField::from_vec(
215-
directories
216-
.iter_mut()
217-
.map(|directory| directory.take_files().into_iter())
218-
.flatten()
219-
.collect(),
211+
Itertools::flatten(
212+
directories
213+
.iter_mut()
214+
.map(|directory| directory.take_files().into_iter()),
215+
).collect(),
220216
));
221217
out_dir.mut_files().sort_by(|a, b| a.name.cmp(&b.name));
222218
let unique_count = out_dir
@@ -242,11 +238,11 @@ impl Snapshot {
242238

243239
// Group and recurse for DirectoryNodes.
244240
let sorted_child_directories = {
245-
let mut merged_directories = directories
246-
.iter_mut()
247-
.map(|directory| directory.take_directories().into_iter())
248-
.flatten()
249-
.collect::<Vec<_>>();
241+
let mut merged_directories = Itertools::flatten(
242+
directories
243+
.iter_mut()
244+
.map(|directory| directory.take_directories().into_iter()),
245+
).collect::<Vec<_>>();
250246
merged_directories.sort_by(|a, b| a.name.cmp(&b.name));
251247
merged_directories
252248
};
@@ -356,15 +352,15 @@ mod tests {
356352
extern crate tempdir;
357353
extern crate testutil;
358354

355+
use self::testutil::data::TestDirectory;
356+
use self::testutil::make_file;
359357
use futures::future::Future;
360358
use hashing::{Digest, Fingerprint};
361359
use tempdir::TempDir;
362-
use self::testutil::make_file;
363-
use self::testutil::data::TestDirectory;
364360

365-
use super::OneOffStoreFileByDigest;
366361
use super::super::{Dir, File, Path, PathGlobs, PathStat, PosixFS, ResettablePool, Snapshot,
367362
Store, VFS};
363+
use super::OneOffStoreFileByDigest;
368364

369365
use std;
370366
use std::path::PathBuf;

src/rust/engine/fs/src/store.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ mod local {
564564
use digest::{Digest as DigestTrait, FixedOutput};
565565
use futures::future;
566566
use hashing::{Digest, Fingerprint};
567+
use lmdb::Error::{KeyExist, NotFound};
567568
use lmdb::{self, Cursor, Database, DatabaseFlags, Environment, RwTransaction, Transaction,
568569
WriteFlags, NO_OVERWRITE, NO_SYNC, NO_TLS};
569-
use lmdb::Error::{KeyExist, NotFound};
570570
use resettable::Resettable;
571571
use sha2::Sha256;
572572
use std::collections::{BinaryHeap, HashMap};
@@ -575,9 +575,9 @@ mod local {
575575
use std::sync::Arc;
576576
use std::time;
577577

578-
use pool::ResettablePool;
579-
use super::MAX_LOCAL_STORE_SIZE_BYTES;
580578
use super::super::EMPTY_FINGERPRINT;
579+
use super::MAX_LOCAL_STORE_SIZE_BYTES;
580+
use pool::ResettablePool;
581581

582582
#[derive(Clone)]
583583
pub struct ByteStore {
@@ -994,11 +994,11 @@ mod local {
994994

995995
#[cfg(test)]
996996
pub mod tests {
997+
use super::super::super::safe_create_dir_all;
998+
use super::{ByteStore, EntryType, ResettablePool};
997999
use bytes::Bytes;
9981000
use futures::Future;
9991001
use hashing::{Digest, Fingerprint};
1000-
use super::{ByteStore, EntryType, ResettablePool};
1001-
use super::super::super::safe_create_dir_all;
10021002
use lmdb::{DatabaseFlags, Environment, Transaction, WriteFlags};
10031003
use std::path::Path;
10041004
use std::sync::Arc;
@@ -1522,8 +1522,8 @@ mod remote {
15221522
use bytes::{Bytes, BytesMut};
15231523
use digest::{Digest as DigestTrait, FixedOutput};
15241524
use futures::{self, future, Future, Sink, Stream};
1525-
use hashing::{Digest, Fingerprint};
15261525
use grpcio;
1526+
use hashing::{Digest, Fingerprint};
15271527
use resettable::Resettable;
15281528
use sha2::Sha256;
15291529
use std::cmp::min;
@@ -1739,8 +1739,8 @@ mod remote {
17391739

17401740
extern crate tempdir;
17411741

1742-
use super::ByteStore;
17431742
use super::super::EntryType;
1743+
use super::ByteStore;
17441744
use bytes::Bytes;
17451745
use futures::Future;
17461746
use hashing::Digest;

src/rust/engine/process_execution/src/local.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ impl super::CommandRunner for CommandRunner {
2727
///
2828
fn run(&self, req: ExecuteProcessRequest) -> BoxFuture<ExecuteProcessResult, String> {
2929
let workdir = try_future!(
30-
tempdir::TempDir::new("process-execution").map_err(|err| format!(
31-
"Error making tempdir for local process execution: {:?}",
32-
err
33-
))
30+
tempdir::TempDir::new("process-execution").map_err(|err| {
31+
format!(
32+
"Error making tempdir for local process execution: {:?}",
33+
err
34+
)
35+
})
3436
);
3537

3638
let store = self.store.clone();
@@ -105,18 +107,18 @@ mod tests {
105107
extern crate tempdir;
106108
extern crate testutil;
107109

110+
use self::testutil::{as_bytes, owned_string_vec};
111+
use super::super::CommandRunner as CommandRunnerTrait;
112+
use super::{ExecuteProcessRequest, ExecuteProcessResult};
108113
use fs;
109114
use futures::Future;
110-
use super::{ExecuteProcessRequest, ExecuteProcessResult};
111-
use super::super::CommandRunner as CommandRunnerTrait;
112115
use std;
113116
use std::collections::{BTreeMap, BTreeSet};
114117
use std::env;
115118
use std::os::unix::fs::PermissionsExt;
116119
use std::path::{Path, PathBuf};
117120
use std::sync::Arc;
118121
use tempdir::TempDir;
119-
use self::testutil::{as_bytes, owned_string_vec};
120122
use testutil::data::{TestData, TestDirectory};
121123

122124
#[test]

src/rust/engine/process_execution/src/remote.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use digest::{Digest as DigestTrait, FixedOutput};
88
use fs::{self, Store};
99
use futures::{future, Future};
1010
use futures_timer::Delay;
11-
use hashing::{Digest, Fingerprint};
1211
use grpcio;
12+
use hashing::{Digest, Fingerprint};
1313
use protobuf::{self, Message, ProtobufEnum};
1414
use resettable::Resettable;
1515
use sha2::Sha256;
@@ -268,10 +268,12 @@ impl CommandRunner {
268268
try_future!(
269269
precondition_failure
270270
.merge_from_bytes(details.get_value())
271-
.map_err(|e| ExecutionError::Fatal(format!(
272-
"Error deserializing FailedPrecondition proto: {:?}",
273-
e
274-
)))
271+
.map_err(|e| {
272+
ExecutionError::Fatal(format!(
273+
"Error deserializing FailedPrecondition proto: {:?}",
274+
e
275+
))
276+
})
275277
);
276278

277279
let mut missing_digests =
@@ -464,14 +466,14 @@ mod tests {
464466
use futures::Future;
465467
use grpcio;
466468
use hashing::Digest;
467-
use protobuf::{self, Message, ProtobufEnum};
468469
use mock;
470+
use protobuf::{self, Message, ProtobufEnum};
469471
use tempdir::TempDir;
470472
use testutil::data::{TestData, TestDirectory};
471473
use testutil::{as_bytes, owned_string_vec};
472474

473-
use super::{CommandRunner, ExecuteProcessRequest, ExecuteProcessResult, ExecutionError};
474475
use super::super::CommandRunner as CommandRunnerTrait;
476+
use super::{CommandRunner, ExecuteProcessRequest, ExecuteProcessResult, ExecutionError};
475477
use std::collections::{BTreeMap, BTreeSet};
476478
use std::iter::{self, FromIterator};
477479
use std::sync::Arc;

src/rust/engine/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use fnv::FnvHasher;
55

66
use std::collections::HashMap;
7-
use std::{fmt, hash};
87
use std::ops::Drop;
8+
use std::{fmt, hash};
99

1010
use externs;
1111
use handles::{enqueue_drop_handle, Handle};

src/rust/engine/src/graph.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use std::io::{self, BufWriter, Write};
88
use std::path::{Path, PathBuf};
99
use std::sync::Mutex;
1010

11+
use futures::future::{self, Future};
1112
use petgraph::Direction;
1213
use petgraph::stable_graph::{NodeIndex, StableDiGraph, StableGraph};
13-
use futures::future::{self, Future};
1414

15-
use externs;
1615
use boxfuture::Boxable;
1716
use context::ContextFactory;
1817
use core::{Failure, Noop, FNV};
18+
use externs;
1919
use hashing;
2020
use nodes::{DigestFile, Node, NodeFuture, NodeKey, NodeResult, TryInto};
2121

@@ -341,7 +341,7 @@ impl InnerGraph {
341341
};
342342

343343
try!(f.write_all(b"digraph plans {\n"));
344-
try!(f.write_fmt(format_args!(" node[colorscheme={}];\n", viz_color_scheme),));
344+
try!(f.write_fmt(format_args!(" node[colorscheme={}];\n", viz_color_scheme)));
345345
try!(f.write_all(b" concentrate=true;\n"));
346346
try!(f.write_all(b" rankdir=TB;\n"));
347347

@@ -371,7 +371,7 @@ impl InnerGraph {
371371

372372
// Write an entry per edge.
373373
let dep_str = dep_entry.format::<NodeKey>();
374-
try!(f.write_fmt(format_args!(" \"{}\" -> \"{}\"\n", node_str, dep_str),));
374+
try!(f.write_fmt(format_args!(" \"{}\" -> \"{}\"\n", node_str, dep_str)));
375375
}
376376
}
377377

0 commit comments

Comments
 (0)