Skip to content

Commit

Permalink
cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bierbaum committed Nov 10, 2022
1 parent 2df31aa commit e1e123d
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions content-addressed-cache/src/synchronizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl CacheSynchronizer for GitBackedCacheSynchronizer {
&vec_of_prev_commit_references[..],
)?;

let refspecs = vec![refspec_fmt(&self.namespace, &keyset_id)];
let refspecs = vec![refspec_fmt(&self.namespace, keyset_id)];

self.repo
.reference(
Expand Down Expand Up @@ -593,7 +593,7 @@ mod tests {

#[test]
pub fn refspec_formatting() {
assert_eq!(refspec_fmt("cache", &keyset_id_1()), String::from("+refs/tags/cache/abcd1abcd1abcd1abcd100000000000000000000:refs/tags/cache/abcd1abcd1abcd1abcd100000000000000000000"));
assert_eq!(refspec_fmt("cache", keyset_id_1()), String::from("+refs/tags/cache/abcd1abcd1abcd1abcd100000000000000000000:refs/tags/cache/abcd1abcd1abcd1abcd100000000000000000000"));
assert_eq!(
refspec_fmt("cache", "foo"),
String::from("+refs/tags/cache/foo:refs/tags/cache/foo")
Expand All @@ -603,7 +603,7 @@ mod tests {
#[test]
pub fn tag_formatting() {
assert_eq!(
tag_fmt("cache", &keyset_id_1()),
tag_fmt("cache", keyset_id_1()),
String::from("refs/tags/cache/abcd1abcd1abcd1abcd100000000000000000000"),
);
assert_eq!(tag_fmt("cache", "foo"), String::from("refs/tags/cache/foo"));
Expand Down
18 changes: 9 additions & 9 deletions focus/internals/src/lib/model/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<T: Default + DeserializeOwned + Serialize> FileBackedCollection<T> {
let path = self.make_path(name);
debug!(?path, %name, "Insert");
self.underlying.insert(name.to_owned(), entity.clone());
store_model(&path.as_path(), entity)
store_model(path.as_path(), entity)
}

/// Remove an entity by name from the `underlying` cache and erase it from disk.
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<T: Default + DeserializeOwned + Serialize> FileBackedCollection<T> {
{
for (name, entity) in self.underlying.iter() {
let path = self.make_path(name);
store_model(&path.as_path(), entity)
store_model(path.as_path(), entity)
.with_context(|| format!("Storing entity to {}", path.display()))?
}

Expand All @@ -198,7 +198,7 @@ impl<T: Default + DeserializeOwned + Serialize> FileBackedCollection<T> {
serde_json::to_string(entity)?,
path.display()
);
store_model(&path.as_path(), entity)
store_model(path.as_path(), entity)
.with_context(|| format!("Storing entity to {}", path.display()))
}
}
Expand Down Expand Up @@ -226,8 +226,8 @@ mod tests {
focus_testing::init_logging();

let dir = tempfile::tempdir()?;
let mut collection = make_collection(&dir.path())?;
let mut alternate_collection = make_collection(&dir.path())?;
let mut collection = make_collection(dir.path())?;
let mut alternate_collection = make_collection(dir.path())?;

let name = "jeff";
collection.insert(
Expand Down Expand Up @@ -259,7 +259,7 @@ mod tests {
let dir = tempfile::tempdir()?;
let name = "lebowski";
{
let mut collection = make_collection(&dir.path())?;
let mut collection = make_collection(dir.path())?;

collection.insert(
name,
Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {
}

{
let collection = make_collection(&dir.path())?;
let collection = make_collection(dir.path())?;
let (actual_name, entity) = collection.underlying.iter().next().unwrap();
assert_eq!(actual_name, name);
assert_eq!(entity.name, "Maude Lebowski");
Expand All @@ -301,7 +301,7 @@ mod tests {
focus_testing::init_logging();
let dir = tempfile::tempdir()?;
{
let mut collection = make_collection(&dir.path())?;
let mut collection = make_collection(dir.path())?;
{
collection.underlying.insert(
String::from("foo"),
Expand All @@ -321,7 +321,7 @@ mod tests {
}

{
let collection = make_collection(&dir.path())?;
let collection = make_collection(dir.path())?;
assert!(collection.underlying.contains_key("foo"));
assert!(collection.underlying.contains_key("bar"));
}
Expand Down
2 changes: 1 addition & 1 deletion focus/internals/src/lib/model/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ pub struct Repo {

impl Repo {
pub fn open(path: &Path, app: Arc<App>) -> Result<Self> {
let repo = git2::Repository::open(&path)
let repo = git2::Repository::open(path)
.with_context(|| format!("Opening repo {}", path.display()))
.context("Failed to open repo")?;
if repo.is_bare() {
Expand Down
4 changes: 2 additions & 2 deletions focus/internals/src/lib/project_cache/local_cache_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl LocalCacheBackend {
impl ProjectCacheBackend for LocalCacheBackend {
fn load_model(&self, url: Url) -> Result<Vec<u8>> {
let key = url.path();
if let Ok(Some(repr)) = self.database.borrow().get(&key) {
if let Ok(Some(repr)) = self.database.borrow().get(key) {
debug!(?key, "GET: Found");
Ok(repr)
} else {
Expand All @@ -55,7 +55,7 @@ impl ProjectCacheBackend for LocalCacheBackend {
let key = url.path();
debug!(?key, "PUT");
self.database
.put(&key, value)
.put(key, value)
.with_context(|| format!("Writing key '{}' failed", &key))
}

Expand Down
4 changes: 2 additions & 2 deletions focus/internals/src/lib/project_cache/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn manifest_path(backend: &dyn ProjectCacheBackend, build_graph_hash: &Vec<u8>)
let path = format!(
"{}/{}.manifest_v{}.json.gz",
url.path(),
hex::encode(&build_graph_hash).as_str(),
hex::encode(build_graph_hash).as_str(),
PROJECT_CACHE_VERSION,
);
url.set_path(&path);
Expand All @@ -53,7 +53,7 @@ fn export_path(
let path = format!(
"{}/{}_{}_{}.export_v{}.json.gz",
url.path(),
hex::encode(&build_graph_hash).as_str(),
hex::encode(build_graph_hash).as_str(),
shard_index + 1,
shard_count,
PROJECT_CACHE_VERSION,
Expand Down
10 changes: 5 additions & 5 deletions focus/operations/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tracing::{debug, error, info, info_span, warn};
use url::Url;

pub fn run_clone(mut clone_builder: CloneBuilder, app: Arc<App>) -> Result<()> {
(&mut clone_builder).add_clone_args(vec!["--progress"]);
clone_builder.add_clone_args(vec!["--progress"]);
let (mut cmd, scmd) = clone_builder.build(app)?;

scmd.ensure_success_or_log(&mut cmd, SandboxCommandOutput::Stderr)
Expand Down Expand Up @@ -487,7 +487,7 @@ fn clone_local(
}

let dense_repo = Repository::open(&dense_repo_path).context("Opening dense repo")?;
let sparse_repo = Repository::open(&sparse_repo_path).context("Opening sparse repo")?;
let sparse_repo = Repository::open(sparse_repo_path).context("Opening sparse repo")?;

if copy_branches {
let span = info_span!("Copying branches");
Expand Down Expand Up @@ -868,7 +868,7 @@ fn set_up_hooks(sparse_repo: &Path) -> Result<()> {
fn fetch_default_remote(sparse_repo: &Path, app: Arc<App>) -> Result<()> {
let (mut cmd, scmd) = git_helper::git_command(app)?;
let _ = scmd.ensure_success_or_log(
cmd.current_dir(&sparse_repo).arg("fetch").arg("origin"),
cmd.current_dir(sparse_repo).arg("fetch").arg("origin"),
SandboxCommandOutput::Stderr,
)?;

Expand Down Expand Up @@ -1280,7 +1280,7 @@ mod twttr_test {
.map(|m| {
m.unwrap()
.path()
.strip_prefix(&outlining_tree_path)
.strip_prefix(outlining_tree_path)
.unwrap()
.to_owned()
})
Expand Down Expand Up @@ -1308,7 +1308,7 @@ mod twttr_test {
.map(|m| {
m.unwrap()
.path()
.strip_prefix(&working_tree_path)
.strip_prefix(working_tree_path)
.unwrap()
.to_owned()
})
Expand Down
4 changes: 2 additions & 2 deletions focus/operations/src/detect_build_graph_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn find_committed_changes(app: Arc<App>, repo_path: &Path) -> Result<Vec<PathBuf

let revspec = format!("{}..HEAD", &sync_state_oid);
let output =
git_helper::run_consuming_stdout(repo_path, &["diff", "--name-only", &revspec], app)?;
git_helper::run_consuming_stdout(repo_path, ["diff", "--name-only", &revspec], app)?;
let mut build_involved_changed_paths = Vec::<PathBuf>::new();
for line in output.lines() {
let parsed = PathBuf::from(line);
Expand All @@ -51,7 +51,7 @@ fn find_committed_changes(app: Arc<App>, repo_path: &Path) -> Result<Vec<PathBuf

fn find_uncommitted_changes(app: Arc<App>, repo: &Path) -> Result<Vec<PathBuf>> {
let output =
git_helper::run_consuming_stdout(repo, &["status", "--porcelain", "--no-renames"], app)?;
git_helper::run_consuming_stdout(repo, ["status", "--porcelain", "--no-renames"], app)?;
let mut build_involved_changed_paths = Vec::<PathBuf>::new();
for line in output.lines() {
let mut tokens = line.split_ascii_whitespace().take(2);
Expand Down
2 changes: 1 addition & 1 deletion focus/operations/src/maintenance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ mod tests {

fn assert_repo_defaults_set(config: &git2::Config) {
for (k, v) in CONFIG_DEFAULTS.iter() {
let val = config.get_string(*k).unwrap();
let val = config.get_string(k).unwrap();
assert_eq!(
val, *v,
"values for key {} were not equal: {} != {}",
Expand Down
12 changes: 6 additions & 6 deletions focus/operations/src/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ pub(crate) mod testing {
// Create `refs/focus/sync`
let _ = git_helper::run_consuming_stdout(
repo_dir,
&["update-ref", "refs/focus/sync", &head],
["update-ref", "refs/focus/sync", &head],
app.clone(),
)?;

// Create a default prefetch ref
let _ = git_helper::run_consuming_stdout(
repo_dir,
&["update-ref", "refs/prefetch/remotes/origin/master", &head],
["update-ref", "refs/prefetch/remotes/origin/master", &head],
app.clone(),
)?;

Expand All @@ -168,7 +168,7 @@ pub(crate) mod testing {
// Create a default remote ref
let _ = git_helper::run_consuming_stdout(
repo_dir,
&["update-ref", "refs/remotes/origin/master", &head],
["update-ref", "refs/remotes/origin/master", &head],
app.clone(),
)?;

Expand All @@ -185,7 +185,7 @@ pub(crate) mod testing {
// Update prefetch default to new commit
let _ = git_helper::run_consuming_stdout(
repo_dir,
&[
[
"update-ref",
"refs/prefetch/remotes/origin/master",
&new_commit,
Expand All @@ -194,15 +194,15 @@ pub(crate) mod testing {
)?;

// Switch back to `main` branch
let _ = git_helper::run_consuming_stdout(repo_dir, &["checkout", "main"], app.clone())?;
let _ = git_helper::run_consuming_stdout(repo_dir, ["checkout", "main"], app.clone())?;

// Since focus/sync still points to `main` HEAD, merge base validation should still fail
assert!(validate_merge_base(app.clone(), repo_dir).is_err());

// Update focus/sync to new commit
let _ = git_helper::run_consuming_stdout(
repo_dir,
&["update-ref", "refs/focus/sync", &new_commit],
["update-ref", "refs/focus/sync", &new_commit],
app.clone(),
)?;

Expand Down
4 changes: 2 additions & 2 deletions focus/operations/src/testing/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl RepoPairFixture {
.command()
.arg("fetch")
.arg(remote_name)
.current_dir(&path)
.current_dir(path)
.assert()
.success();
let fetch_head_path = path.join(".git").join("FETCH_HEAD");
Expand All @@ -195,7 +195,7 @@ impl RepoPairFixture {
.arg("pull")
.arg(remote_name)
.arg(branch)
.current_dir(&path)
.current_dir(path)
.assert()
.success();

Expand Down
6 changes: 3 additions & 3 deletions focus/testing/src/scratch_git_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ScratchGitRepo {
.arg("add")
.arg("--")
.arg(".")
.current_dir(&destination_path)
.current_dir(destination_path)
.assert()
.success();

Expand All @@ -95,7 +95,7 @@ impl ScratchGitRepo {
.arg("commit")
.arg("-m")
.arg("Initial import")
.current_dir(&destination_path)
.current_dir(destination_path)
.assert()
.success();

Expand Down Expand Up @@ -227,7 +227,7 @@ impl ScratchGitRepo {
qualified_origin.push(origin.as_os_str());
git_binary
.command()
.args(&[
.args([
OsStr::new("clone"),
&qualified_origin,
destination.as_os_str(),
Expand Down
4 changes: 2 additions & 2 deletions focus/tracing/src/git_trace2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl Events {

let mut result: Vec<Event> = Vec::new();

let bytes = std::fs::read(&path)?;
let bytes = std::fs::read(path)?;
debug!("parsing: {:?}", &path);
for line in BufReader::new(bytes.as_slice()).lines() {
let s = line?;
Expand Down Expand Up @@ -664,7 +664,7 @@ mod tests {
#[test]
fn test_parse_examples() -> Result<()> {
for (k, v) in data::DATA.iter() {
let xyz: serde_json::Result<Event> = serde_json::from_str(*v);
let xyz: serde_json::Result<Event> = serde_json::from_str(v);
if let Err(e) = xyz {
println!("failure: {}, {:?}", *k, e);
bail!(e)
Expand Down

0 comments on commit e1e123d

Please sign in to comment.