Skip to content

Commit

Permalink
Prepare for rustfmt 2.0
Browse files Browse the repository at this point in the history
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: StanislavGlebik

Differential Revision: D23568780

fbshipit-source-id: b4b4a0aa683d236e2fdeb5b96d723ac2d84b9faf
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Sep 8, 2020
1 parent bf8a8c4 commit be0786f
Show file tree
Hide file tree
Showing 77 changed files with 436 additions and 379 deletions.
96 changes: 49 additions & 47 deletions eden/mononoke/blobrepo/blobrepo_hg/src/bonsai_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,57 +106,59 @@ fn find_file_changes(
cs.manifestid(),
parent_manifests.iter().cloned().collect(),
)
.map(move |changed_file| match changed_file {
BonsaiDiffFileChange::Changed(path, ty, entry_id) => {
let file_node_id = HgFileNodeId::new(entry_id.into_nodehash());
cloned!(ctx, bonsai_parents, repo, parent_manifests);
file_node_id
.load(ctx.clone(), repo.blobstore())
.compat()
.from_err()
.and_then(move |envelope| {
let size = envelope.content_size();
let content_id = envelope.content_id();

get_copy_info(
ctx,
repo,
bonsai_parents,
path.clone(),
envelope,
parent_manifests,
)
.context("While fetching copy information")
.map(move |changed_file| {
match changed_file {
BonsaiDiffFileChange::Changed(path, ty, entry_id) => {
let file_node_id = HgFileNodeId::new(entry_id.into_nodehash());
cloned!(ctx, bonsai_parents, repo, parent_manifests);
file_node_id
.load(ctx.clone(), repo.blobstore())
.compat()
.from_err()
.map(move |copyinfo| {
(
path,
Some(FileChange::new(content_id, ty, size as u64, copyinfo)),
.and_then(move |envelope| {
let size = envelope.content_size();
let content_id = envelope.content_id();

get_copy_info(
ctx,
repo,
bonsai_parents,
path.clone(),
envelope,
parent_manifests,
)
.context("While fetching copy information")
.from_err()
.map(move |copyinfo| {
(
path,
Some(FileChange::new(content_id, ty, size as u64, copyinfo)),
)
})
})
})
.boxify()
}
BonsaiDiffFileChange::ChangedReusedId(path, ty, entry_id) => {
let file_node_id = HgFileNodeId::new(entry_id.into_nodehash());
cloned!(ctx, repo);
file_node_id
.load(ctx, repo.blobstore())
.compat()
.from_err()
.and_then(move |envelope| {
let size = envelope.content_size();
let content_id = envelope.content_id();

// Reused ID means copy info is *not* stored.
Ok((
path,
Some(FileChange::new(content_id, ty, size as u64, None)),
))
})
.boxify()
.boxify()
}
BonsaiDiffFileChange::ChangedReusedId(path, ty, entry_id) => {
let file_node_id = HgFileNodeId::new(entry_id.into_nodehash());
cloned!(ctx, repo);
file_node_id
.load(ctx, repo.blobstore())
.compat()
.from_err()
.and_then(move |envelope| {
let size = envelope.content_size();
let content_id = envelope.content_id();

// Reused ID means copy info is *not* stored.
Ok((
path,
Some(FileChange::new(content_id, ty, size as u64, None)),
))
})
.boxify()
}
BonsaiDiffFileChange::Deleted(path) => Ok((path, None)).into_future().boxify(),
}
BonsaiDiffFileChange::Deleted(path) => Ok((path, None)).into_future().boxify(),
})
.buffer_unordered(100) // TODO(stash): magic number?
.collect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub fn check_case_conflict_in_manifest(
potential_conflicts.extend(path);
}
}
_ => (),
_ => {}
}
}

Expand Down
26 changes: 14 additions & 12 deletions eden/mononoke/blobrepo/blobrepo_hg/src/derive_hg_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ pub fn derive_hg_manifest(
move |leaf_info, _sender| create_hg_file(ctx.clone(), blobstore.clone(), leaf_info)
},
)
.and_then(move |tree_id| match tree_id {
Some(traced_tree_id) => future::ok(traced_tree_id.into_untraced()).left_future(),
None => {
// All files have been deleted, generate empty **root** manifest
let tree_info = TreeInfo {
path: None,
parents,
subentries: Default::default(),
};
create_hg_manifest(ctx, blobstore, None, tree_info)
.map(|(_, traced_tree_id)| traced_tree_id.into_untraced())
.right_future()
.and_then(move |tree_id| {
match tree_id {
Some(traced_tree_id) => future::ok(traced_tree_id.into_untraced()).left_future(),
None => {
// All files have been deleted, generate empty **root** manifest
let tree_info = TreeInfo {
path: None,
parents,
subentries: Default::default(),
};
create_hg_manifest(ctx, blobstore, None, tree_info)
.map(|(_, traced_tree_id)| traced_tree_id.into_untraced())
.right_future()
}
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions eden/mononoke/blobrepo/blobsync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn copy_content(
"File not found for fetch key: {:?}",
fetch_key
))
.left_future()
.left_future();
}
};

Expand All @@ -76,7 +76,7 @@ pub fn copy_content(
"File not found for fetch key: {:?}",
fetch_key
))
.left_future()
.left_future();
}
Some(byte_stream) => {
ok((store_request, byte_stream)).right_future()
Expand Down
12 changes: 9 additions & 3 deletions eden/mononoke/blobrepo/errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,21 @@ pub enum ErrorKind {
BonsaiMappingNotFound(HgChangesetId),
#[error("Root path wasn't expected at this context")]
UnexpectedRootPath,
#[error("Incorrect copy info: not found a file version {from_path} {from_node} the file {to_path} {to_node} was copied from")]
#[error(
"Incorrect copy info: not found a file version {from_path} {from_node} the file {to_path} {to_node} was copied from"
)]
IncorrectCopyInfo {
from_path: MPath,
from_node: HgFileNodeId,
to_path: MPath,
to_node: HgFileNodeId,
},
#[error("CaseConflict: the changes introduced by this commit have conflicting case. The first offending path is '{0}'. Resolve the conflict.")]
#[error(
"CaseConflict: the changes introduced by this commit have conflicting case. The first offending path is '{0}'. Resolve the conflict."
)]
InternalCaseConflict(MPath),
#[error("CaseConflict: the changes introduced by this commit conflict with existing files in the repository. The first conflicting path in this commit was '{0}', and conflicted with '{1}' in the repository. Resolve the conflict.")]
#[error(
"CaseConflict: the changes introduced by this commit conflict with existing files in the repository. The first conflicting path in this commit was '{0}', and conflicted with '{1}' in the repository. Resolve the conflict."
)]
ExternalCaseConflict(MPath, MPath),
}
8 changes: 4 additions & 4 deletions eden/mononoke/blobstore/cacheblob/src/memcache_cache_lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ impl LeaseOps for MemcacheOps {
// This future checks the state of the lease, and releases it only
// if it's locked by us right now.
let f = future::lazy(move || {
memcache
.get(mc_key.clone())
.and_then(move |maybe_data| match maybe_data {
memcache.get(mc_key.clone()).and_then(move |maybe_data| {
match maybe_data {
Some(bytes) => {
let state: Result<LockState, Error> =
compact_protocol::deserialize(Vec::from(bytes));
Expand Down Expand Up @@ -399,7 +398,8 @@ impl LeaseOps for MemcacheOps {
LEASE_STATS::release_no_lease.add_value(1, (lease_type,));
future::ok(()).right_future()
}
})
}
})
});
// We don't have to wait for the releasing to finish, it can be done in background
// because leases have a timeout. So even if they haven't been released explicitly they
Expand Down
4 changes: 2 additions & 2 deletions eden/mononoke/blobstore/multiplexedblob/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async fn blobstore_get(
(blobstore_id, Err(error)) => {
errors.insert(blobstore_id, error);
}
(_, Ok(None)) => (),
(_, Ok(None)) => {}
}
}

Expand Down Expand Up @@ -545,7 +545,7 @@ impl Blobstore for MultiplexedBlobstoreBase {
(blobstore_id, Err(error)) => {
errors.insert(blobstore_id, error);
}
(_, Ok(false)) => (),
(_, Ok(false)) => {}
}
}
if errors.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion eden/mononoke/blobstore/multiplexedblob/src/scrub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async fn blobstore_get(
needs_repair.insert(*k, s.as_ref());
}
}
None => (),
None => {}
}
}
if scrub_action == ScrubAction::ReportOnly {
Expand Down
6 changes: 3 additions & 3 deletions eden/mononoke/blobstore/packblob/src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ pub fn decode_pack(
return Err(format_err!(
"Unexpected PackedValue::Single on key {}",
&key
))
));
}
PackedValue::ZstdFromDict(v) => {
return Ok(decode_zstd_from_dict(pack_meta, &key, v, possible_dicts)?)
return Ok(decode_zstd_from_dict(pack_meta, &key, v, possible_dicts)?);
}
PackedValue::UnknownField(e) => {
return Err(format_err!("PackedValue::UnknownField {:?}", e))
return Err(format_err!("PackedValue::UnknownField {:?}", e));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion eden/mononoke/blobstore/packblob/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<T: Blobstore + Clone> Blobstore for PackBlob<T> {
StorageFormat::Packed(packed) => pack::decode_pack(meta, packed, key.clone())
.with_context(|| format!("While decoding pack for {:?}", key))?,
StorageFormat::UnknownField(e) => {
return Err(format_err!("StorageFormat::UnknownField {:?}", e))
return Err(format_err!("StorageFormat::UnknownField {:?}", e));
}
};

Expand Down
1 change: 0 additions & 1 deletion eden/mononoke/blobstore/redactedblobstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ pub fn has_redaction_root_cause(e: &Error) -> bool {

#[cfg(test)]
mod test {

use super::*;
use assert_matches::assert_matches;
use context::CoreContext;
Expand Down
2 changes: 1 addition & 1 deletion eden/mononoke/bonsai_git_mapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl BonsaiGitMapping for SqlBonsaiGitMapping {

for entry in entries.iter() {
match mapping_from_db.get(&entry.git_sha1) {
Some(bcs_id) if bcs_id == &entry.bcs_id => (), // We've tried to insert a duplicate, proceed.
Some(bcs_id) if bcs_id == &entry.bcs_id => {} // We've tried to insert a duplicate, proceed.
_ => {
return Err(AddGitMappingErrorKind::Conflict(vec![entry.clone()].into()));
} // A real conflict!
Expand Down
6 changes: 3 additions & 3 deletions eden/mononoke/bookmarks/dbbookmarks/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl SqlBookmarksTransactionPayload {
return Err(anyhow!(
"FindMaxBookmarkLogId returned multiple entries: {:?}",
max_id_entries
))
));
}
};
Ok((txn, next_id))
Expand Down Expand Up @@ -542,7 +542,7 @@ impl BookmarkTransaction for SqlBookmarksTransaction {
Err(BookmarkTransactionError::RetryableError(_))
if attempt < MAX_BOOKMARK_TRANSACTION_ATTEMPT_COUNT =>
{
continue
continue;
}
err => break err,
};
Expand All @@ -551,7 +551,7 @@ impl BookmarkTransaction for SqlBookmarksTransaction {
Err(BookmarkTransactionError::RetryableError(_))
if attempt < MAX_BOOKMARK_TRANSACTION_ATTEMPT_COUNT =>
{
continue
continue;
}
result => break result,
}
Expand Down
1 change: 0 additions & 1 deletion eden/mononoke/changesets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ fn select_many_changesets(

#[cfg(test)]
mod tests {

use super::*;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion eden/mononoke/cmds/admin/blobstore_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub async fn subcommand_blobstore_fetch<'a>(
FileContents::from_encoded_bytes(value.into_raw_bytes())
),
Some("git-tree") => display::<GitTree>(&value.try_into()),
_ => (),
_ => {}
}
}
}
Expand Down
Loading

0 comments on commit be0786f

Please sign in to comment.