Skip to content

Commit 9a1d43a

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 e001a50 commit 9a1d43a

File tree

13 files changed

+58
-63
lines changed

13 files changed

+58
-63
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/fs/brfs/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,13 @@ mod test {
639639
extern crate tempdir;
640640
extern crate testutil;
641641

642+
use self::tempdir::TempDir;
643+
use self::testutil::{file, data::{TestData, TestDirectory}};
644+
use super::mount;
642645
use fs;
643646
use futures::future::Future;
644647
use hashing;
645-
use self::tempdir::TempDir;
646648
use std::sync::Arc;
647-
use super::mount;
648-
use self::testutil::{file, data::{TestData, TestDirectory}};
649649

650650
#[test]
651651
fn missing_digest() {
@@ -884,16 +884,16 @@ mod syscall_tests {
884884
extern crate tempdir;
885885
extern crate testutil;
886886

887+
use self::tempdir::TempDir;
888+
use self::testutil::data::TestData;
889+
use super::mount;
890+
use super::test::digest_to_filepath;
887891
use fs;
888892
use futures::Future;
889893
use libc;
890-
use std::sync::Arc;
891-
use super::mount;
892-
use super::test::digest_to_filepath;
893-
use self::tempdir::TempDir;
894-
use self::testutil::data::TestData;
895894
use std::ffi::CString;
896895
use std::path::Path;
896+
use std::sync::Arc;
897897

898898
#[test]
899899
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
@@ -36,13 +36,13 @@ extern crate tempdir;
3636
#[cfg(test)]
3737
extern crate testutil;
3838

39+
use std::cmp::min;
3940
use std::collections::HashSet;
41+
use std::io::{self, Read};
4042
use std::os::unix::fs::PermissionsExt;
4143
use std::path::{Component, Path, PathBuf};
4244
use std::sync::Arc;
4345
use std::{fmt, fs};
44-
use std::io::{self, Read};
45-
use std::cmp::min;
4646

4747
use bytes::Bytes;
4848
use futures::future::{self, Future};
@@ -122,12 +122,9 @@ impl PathStat {
122122

123123
lazy_static! {
124124
static ref PARENT_DIR: &'static str = "..";
125-
126125
static ref SINGLE_STAR_GLOB: Pattern = Pattern::new("*").unwrap();
127-
128126
static ref DOUBLE_STAR: &'static str = "**";
129127
static ref DOUBLE_STAR_GLOB: Pattern = Pattern::new("**").unwrap();
130-
131128
static ref EMPTY_IGNORE: Arc<Gitignore> = Arc::new(Gitignore::empty());
132129
}
133130

@@ -851,9 +848,9 @@ mod posixfs_test {
851848
extern crate tempdir;
852849
extern crate testutil;
853850

851+
use self::testutil::make_file;
854852
use super::{Dir, File, Link, PathStat, PathStatGetter, PosixFS, ResettablePool, Stat};
855853
use futures::Future;
856-
use self::testutil::make_file;
857854
use std;
858855
use std::path::{Path, PathBuf};
859856
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: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ use futures::future::{self, join_all};
1111
use hashing::{Digest, Fingerprint};
1212
use indexmap::{self, IndexMap};
1313
use itertools::Itertools;
14-
use {File, FileContent, PathStat, PosixFS, Store};
1514
use protobuf;
1615
use std::collections::HashMap;
1716
use std::ffi::OsString;
1817
use std::fmt;
1918
use std::path::PathBuf;
2019
use std::sync::{Arc, Mutex};
20+
use {File, FileContent, PathStat, PosixFS, Store};
2121

2222
const EMPTY_FINGERPRINT: Fingerprint = Fingerprint([
2323
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24,
@@ -154,11 +154,7 @@ impl Snapshot {
154154
// `Directory` structure. Only `Dir+Dir` collisions are legal.
155155
let path_stats = {
156156
let mut uniq_paths: IndexMap<PathBuf, PathStat> = IndexMap::new();
157-
for path_stat in snapshots
158-
.iter()
159-
.map(|s| s.path_stats.iter().cloned())
160-
.flatten()
161-
{
157+
for path_stat in Itertools::flatten(snapshots.iter().map(|s| s.path_stats.iter().cloned())) {
162158
match uniq_paths.entry(path_stat.path().to_owned()) {
163159
indexmap::map::Entry::Occupied(e) => match (&path_stat, e.get()) {
164160
(&PathStat::Dir { .. }, &PathStat::Dir { .. }) => (),
@@ -215,21 +211,21 @@ impl Snapshot {
215211

216212
// Merge FileNodes.
217213
out_dir.set_files(protobuf::RepeatedField::from_vec(
218-
directories
219-
.iter_mut()
220-
.map(|directory| directory.take_files().into_iter())
221-
.flatten()
222-
.collect(),
214+
Itertools::flatten(
215+
directories
216+
.iter_mut()
217+
.map(|directory| directory.take_files().into_iter()),
218+
).collect(),
223219
));
224220
out_dir.mut_files().sort_by(|a, b| a.name.cmp(&b.name));
225221

226222
// Group and recurse for DirectoryNodes.
227223
let sorted_child_directories = {
228-
let mut merged_directories = directories
229-
.iter_mut()
230-
.map(|directory| directory.take_directories().into_iter())
231-
.flatten()
232-
.collect::<Vec<_>>();
224+
let mut merged_directories = Itertools::flatten(
225+
directories
226+
.iter_mut()
227+
.map(|directory| directory.take_directories().into_iter()),
228+
).collect::<Vec<_>>();
233229
merged_directories.sort_by(|a, b| a.name.cmp(&b.name));
234230
merged_directories
235231
};
@@ -424,15 +420,15 @@ mod tests {
424420
extern crate tempdir;
425421
extern crate testutil;
426422

423+
use self::testutil::make_file;
427424
use bytes::Bytes;
428425
use futures::future::Future;
429426
use hashing::{Digest, Fingerprint};
430427
use tempdir::TempDir;
431-
use self::testutil::make_file;
432428

433-
use super::OneOffStoreFileByDigest;
434429
use super::super::{Dir, File, FileContent, Path, PathGlobs, PathStat, PosixFS, ResettablePool,
435430
Snapshot, Store, VFS};
431+
use super::OneOffStoreFileByDigest;
436432

437433
use std;
438434
use std::path::PathBuf;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ mod local {
488488
use bytes::Bytes;
489489
use digest::{Digest as DigestTrait, FixedOutput};
490490
use hashing::{Digest, Fingerprint};
491+
use lmdb::Error::{KeyExist, NotFound};
491492
use lmdb::{self, Cursor, Database, DatabaseFlags, Environment, RwTransaction, Transaction,
492493
WriteFlags, NO_OVERWRITE, NO_SYNC, NO_TLS};
493-
use lmdb::Error::{KeyExist, NotFound};
494494
use resettable::Resettable;
495495
use sha2::Sha256;
496496
use std::collections::{BinaryHeap, HashMap};
@@ -499,8 +499,8 @@ mod local {
499499
use std::sync::Arc;
500500
use std::time;
501501

502-
use pool::ResettablePool;
503502
use super::MAX_LOCAL_STORE_SIZE_BYTES;
503+
use pool::ResettablePool;
504504

505505
#[derive(Clone)]
506506
pub struct ByteStore {
@@ -910,11 +910,11 @@ mod local {
910910

911911
#[cfg(test)]
912912
pub mod tests {
913+
use super::super::super::safe_create_dir_all;
914+
use super::{ByteStore, EntryType, ResettablePool};
913915
use bytes::Bytes;
914916
use futures::Future;
915917
use hashing::{Digest, Fingerprint};
916-
use super::{ByteStore, EntryType, ResettablePool};
917-
use super::super::super::safe_create_dir_all;
918918
use lmdb::{DatabaseFlags, Environment, Transaction, WriteFlags};
919919
use std::path::Path;
920920
use std::sync::Arc;
@@ -1412,8 +1412,8 @@ mod remote {
14121412
use bytes::{Bytes, BytesMut};
14131413
use digest::{Digest as DigestTrait, FixedOutput};
14141414
use futures::{self, future, Future, Sink, Stream};
1415-
use hashing::{Digest, Fingerprint};
14161415
use grpcio;
1416+
use hashing::{Digest, Fingerprint};
14171417
use resettable::Resettable;
14181418
use sha2::Sha256;
14191419
use std::cmp::min;
@@ -1629,8 +1629,8 @@ mod remote {
16291629

16301630
extern crate tempdir;
16311631

1632-
use super::ByteStore;
16331632
use super::super::EntryType;
1633+
use super::ByteStore;
16341634
use bytes::Bytes;
16351635
use futures::Future;
16361636
use hashing::Digest;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ pub fn run_command_locally(
3434
mod tests {
3535
extern crate testutil;
3636

37+
use self::testutil::{as_bytes, owned_string_vec};
3738
use super::{run_command_locally, ExecuteProcessRequest, ExecuteProcessResult};
3839
use fs;
3940
use std::collections::BTreeMap;
4041
use std::path::PathBuf;
41-
use self::testutil::{as_bytes, owned_string_vec};
4242

4343
#[test]
4444
#[cfg(unix)]

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use digest::{Digest as DigestTrait, FixedOutput};
88
use fs::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;
@@ -38,14 +38,14 @@ enum ExecutionError {
3838
}
3939

4040
macro_rules! try_future {
41-
( $x:expr) => {
42-
{
43-
match $x {
44-
Ok(value) => {value}
45-
Err(error) => {return future::err(error).to_boxed();}
46-
}
41+
($x:expr) => {{
42+
match $x {
43+
Ok(value) => value,
44+
Err(error) => {
45+
return future::err(error).to_boxed();
46+
}
4747
}
48-
};
48+
}};
4949
}
5050

5151
impl CommandRunner {
@@ -278,10 +278,12 @@ impl CommandRunner {
278278
try_future!(
279279
precondition_failure
280280
.merge_from_bytes(details.get_value())
281-
.map_err(|e| ExecutionError::Fatal(format!(
282-
"Error deserializing FailedPrecondition proto: {:?}",
283-
e
284-
)))
281+
.map_err(|e| {
282+
ExecutionError::Fatal(format!(
283+
"Error deserializing FailedPrecondition proto: {:?}",
284+
e
285+
))
286+
})
285287
);
286288

287289
let mut missing_digests =
@@ -474,8 +476,8 @@ mod tests {
474476
use futures::Future;
475477
use grpcio;
476478
use hashing::Digest;
477-
use protobuf::{self, Message, ProtobufEnum};
478479
use mock;
480+
use protobuf::{self, Message, ProtobufEnum};
479481
use tempdir::TempDir;
480482
use testutil::data::{TestData, TestDirectory};
481483
use testutil::{as_bytes, owned_string_vec};

src/rust/engine/process_executor/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ extern crate tempdir;
1010
use clap::{App, AppSettings, Arg};
1111
use futures::future::Future;
1212
use hashing::{Digest, Fingerprint};
13-
use tempdir::TempDir;
1413
use std::collections::BTreeMap;
1514
use std::iter::Iterator;
1615
use std::process::exit;
1716
use std::sync::Arc;
1817
use std::time::Duration;
18+
use tempdir::TempDir;
1919

2020
/// A binary which takes args of format:
2121
/// process_executor --env=FOO=bar --env=SOME=value --input-digest=abc123 --input-digest-length=80

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

src/rust/engine/src/nodes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
extern crate bazel_protos;
55
extern crate tempdir;
66

7-
use std::error::Error;
87
use std::collections::BTreeMap;
8+
use std::error::Error;
99
use std::fmt;
1010
use std::os::unix::ffi::OsStrExt;
1111
use std::path::{Path, PathBuf};
@@ -19,8 +19,8 @@ use context::Context;
1919
use core::{throw, Failure, Key, Noop, TypeConstraint, Value, Variants};
2020
use externs;
2121
use fs::{self, Dir, File, FileContent, Link, PathGlobs, PathStat, StoreFileByDigest, VFS};
22-
use process_execution;
2322
use hashing;
23+
use process_execution;
2424
use rule_graph;
2525
use selectors::{self, Selector};
2626
use tasks::{self, Intrinsic, IntrinsicKind};

src/rust/engine/src/rule_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Licensed under the Apache License, Version 2.0 (see LICENSE).
33

44
use std::collections::{hash_map, HashMap, HashSet, VecDeque};
5-
use std::hash::Hash;
65
use std::fmt;
6+
use std::hash::Hash;
77
use std::io;
88

99
use core::{Function, Key, TypeConstraint, TypeId, Value, ANY_TYPE};

0 commit comments

Comments
 (0)