Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Mar 29, 2022
1 parent d79b506 commit 7cf3545
Show file tree
Hide file tree
Showing 54 changed files with 209 additions and 161 deletions.
3 changes: 1 addition & 2 deletions experiments/object-access/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::{path::Path, sync::Arc, time::Instant};

use anyhow::anyhow;
use git_repository::ThreadSafeRepository;
use git_repository::{hash::ObjectId, odb, threading::OwnShared};
use git_repository::{hash::ObjectId, odb, threading::OwnShared, ThreadSafeRepository};

use crate::odb::Cache;

Expand Down
3 changes: 2 additions & 1 deletion git-attributes/src/parse/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bstr::{BStr, BString, ByteSlice};
use std::borrow::Cow;

use bstr::{BStr, BString, ByteSlice};

#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum Kind {
Expand Down
3 changes: 2 additions & 1 deletion git-attributes/src/parse/ignore.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::ignore;
use bstr::{BString, ByteSlice};

use crate::ignore;

pub struct Lines<'a> {
lines: bstr::Lines<'a>,
line_no: usize,
Expand Down
3 changes: 1 addition & 2 deletions git-attributes/tests/parse/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bstr::{BStr, ByteSlice};
use git_attributes::ignore::pattern::Mode;
use git_attributes::{parse, State};
use git_attributes::{ignore::pattern::Mode, parse, State};
use git_testtools::fixture_bytes;

#[test]
Expand Down
16 changes: 8 additions & 8 deletions git-config/src/file/git_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ pub struct GitConfig<'event> {
}

pub mod from_paths {
use crate::parser;
use crate::values::path::interpolate;
use quick_error::quick_error;
use std::borrow::Cow;

use quick_error::quick_error;

use crate::{parser, values::path::interpolate};

quick_error! {
#[derive(Debug)]
/// The error returned by [`GitConfig::from_paths()`][super::GitConfig::from_paths()] and [`GitConfig::from_env_paths()`][super::GitConfig::from_env_paths()].
Expand Down Expand Up @@ -174,9 +175,10 @@ pub mod from_paths {
}

pub mod from_env {
use quick_error::quick_error;

use super::from_paths;
use crate::values::path::interpolate;
use quick_error::quick_error;

quick_error! {
#[derive(Debug)]
Expand Down Expand Up @@ -1796,11 +1798,10 @@ a"#,
mod from_paths_tests {
use std::{fs, io};

use crate::file::from_paths;
use tempfile::tempdir;

use super::{from_paths::Error, Cow, GitConfig};
use crate::parser::ParserOrIoError;
use crate::{file::from_paths, parser::ParserOrIoError};

/// Escapes backslash when writing a path as string so that it is a valid windows path
fn escape_backslashes(path: &std::path::Path) -> String {
Expand Down Expand Up @@ -2261,12 +2262,11 @@ mod from_paths_tests {
mod from_env_tests {
use std::{env, fs};

use crate::file::from_paths;
use crate::file::from_paths::Options;
use serial_test::serial;
use tempfile::tempdir;

use super::{from_env, Cow, GitConfig};
use crate::file::{from_paths, from_paths::Options};

struct Env<'a> {
altered_vars: Vec<&'a str>,
Expand Down
3 changes: 1 addition & 2 deletions git-config/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::{
path::{Path, PathBuf},
};

use crate::file::from_paths;
use crate::file::{GitConfig, GitConfigError};
use crate::file::{from_paths, GitConfig, GitConfigError};

#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum ConfigSource {
Expand Down
8 changes: 4 additions & 4 deletions git-config/src/values.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Rust containers for valid `git-config` types.

use quick_error::quick_error;
use std::{borrow::Cow, convert::TryFrom, fmt::Display, str::FromStr};

use quick_error::quick_error;
#[cfg(feature = "serde")]
use serde::{Serialize, Serializer};

Expand Down Expand Up @@ -288,8 +288,7 @@ pub mod path {
mod interpolate_tests {
use std::borrow::Cow;

use crate::values::b;
use crate::values::{path::interpolate::Error, Path};
use crate::values::{b, path::interpolate::Error, Path};

#[test]
fn no_interpolation_for_paths_without_tilde_or_prefix() {
Expand Down Expand Up @@ -1383,9 +1382,10 @@ mod boolean {

#[cfg(test)]
mod integer {
use std::convert::TryFrom;

use super::{Integer, IntegerSuffix};
use crate::values::b;
use std::convert::TryFrom;

#[test]
fn from_str_no_suffix() {
Expand Down
3 changes: 2 additions & 1 deletion git-features/src/parallel/in_parallel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::parallel::{num_threads, Reduce};
use std::sync::atomic::{AtomicBool, Ordering};

use crate::parallel::{num_threads, Reduce};

/// Runs `left` and `right` in parallel, returning their output when both are done.
pub fn join<O1: Send, O2: Send>(left: impl FnOnce() -> O1 + Send, right: impl FnOnce() -> O2 + Send) -> (O1, O2) {
crossbeam_utils::thread::scope(|s| {
Expand Down
6 changes: 4 additions & 2 deletions git-hash/src/owned/prefix.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{oid, ObjectId, Prefix};
use quick_error::quick_error;
use std::cmp::Ordering;

use quick_error::quick_error;

use crate::{oid, ObjectId, Prefix};

quick_error! {
/// The error returned by [Prefix::try_from_id()][super::Prefix::try_from_id()].
#[derive(Debug)]
Expand Down
6 changes: 4 additions & 2 deletions git-hash/tests/oid/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
mod prefix {
mod cmp_oid {
use git_testtools::hex_to_id;
use std::cmp::Ordering;

use git_testtools::hex_to_id;

#[test]
fn it_detects_inequality() {
let prefix = git_hash::Prefix::new(hex_to_id("b920bbb055e1efb9080592a409d3975738b6efb3"), 7).unwrap();
Expand Down Expand Up @@ -30,9 +31,10 @@ mod prefix {
}
}
mod new {
use std::cmp::Ordering;

use git_hash::{Kind, ObjectId};
use git_testtools::hex_to_id;
use std::cmp::Ordering;

#[test]
fn various_valid_inputs() {
Expand Down
3 changes: 2 additions & 1 deletion git-mailmap/src/entry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::Entry;
use bstr::BStr;

use crate::Entry;

/// Acccess
impl<'a> Entry<'a> {
/// The name to map to.
Expand Down
3 changes: 2 additions & 1 deletion git-mailmap/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ mod error {
}
}

use crate::Entry;
use bstr::{BStr, ByteSlice};
pub use error::Error;

use crate::Entry;

/// An iterator to parse mailmap lines on-demand.
pub struct Lines<'a> {
lines: bstr::Lines<'a>,
Expand Down
10 changes: 6 additions & 4 deletions git-mailmap/src/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::Snapshot;
use std::{cmp::Ordering, ops::Deref};

use bstr::{BStr, BString, ByteSlice};
use git_actor::SignatureRef;
use std::cmp::Ordering;
use std::ops::Deref;

use crate::Snapshot;

/// A resolved signature with borrowed fields for a mapped `name` and/or `email`.
pub struct ResolvedSignature<'a> {
Expand Down Expand Up @@ -311,9 +312,10 @@ fn enriched_signature(

#[cfg(test)]
mod encoded_string {
use crate::snapshot::{EncodedString, EncodedStringRef};
use std::cmp::Ordering;

use crate::snapshot::{EncodedString, EncodedStringRef};

#[test]
fn basic_ascii_case_folding() {
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion git-odb/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::rc::Rc;
use std::{
cell::RefCell,
ops::{Deref, DerefMut},
rc::Rc,
sync::Arc,
};

Expand Down
8 changes: 5 additions & 3 deletions git-odb/src/store_impls/dynamic/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ mod error {
}
}
}
use crate::find::{PotentialPrefix, PrefixLookupResult};
use crate::Find;
pub use error::Error;

use crate::store::types::PackId;
use crate::{
find::{PotentialPrefix, PrefixLookupResult},
store::types::PackId,
Find,
};

impl<S> super::Handle<S>
where
Expand Down
4 changes: 2 additions & 2 deletions git-odb/src/store_impls/dynamic/handle.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::convert::{TryFrom, TryInto};
use std::rc::Rc;
use std::{
cell::RefCell,
convert::{TryFrom, TryInto},
ops::Deref,
rc::Rc,
sync::{atomic::Ordering, Arc},
};

Expand Down
5 changes: 2 additions & 3 deletions git-odb/src/store_impls/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ mod access;

///
pub mod structure {
use crate::store::load_index;
use crate::types::IndexAndPacks;
use crate::Store;
use std::path::PathBuf;

use crate::{store::load_index, types::IndexAndPacks, Store};

/// A record of a structural element of an object database.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 1 addition & 2 deletions git-odb/src/store_impls/loose/find.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cmp::Ordering;
use std::{fs, io::Read, path::PathBuf};
use std::{cmp::Ordering, fs, io::Read, path::PathBuf};

use git_features::zlib;

Expand Down
9 changes: 6 additions & 3 deletions git-odb/tests/odb/store/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,12 @@ fn assert_all_indices_loaded(handle: &git_odb::Handle, num_refreshes: usize, ope
}

mod disambiguate_prefix {
use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources};
use std::cmp::Ordering;

use git_odb::find::PotentialPrefix;
use git_testtools::hex_to_id;
use std::cmp::Ordering;

use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources};

#[test]
fn unambiguous_hex_lengths_yield_prefixes_of_exactly_the_given_length() {
Expand Down Expand Up @@ -483,9 +485,10 @@ mod disambiguate_prefix {
}

mod lookup_prefix {
use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources};
use git_testtools::hex_to_id;

use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources};

#[test]
fn returns_none_for_prefixes_without_any_match() {
let (handle, _tmp) = db_with_all_object_sources().unwrap();
Expand Down
3 changes: 2 additions & 1 deletion git-odb/tests/odb/store/loose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ mod contains {
}

mod lookup_prefix {
use crate::store::loose::ldb;
use git_testtools::{fixture_path, hex_to_id};

use crate::store::loose::ldb;

#[test]
fn returns_none_for_prefixes_without_any_match() {
let store = ldb();
Expand Down
6 changes: 2 additions & 4 deletions git-pack/src/index/access.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::cmp::Ordering;
use std::mem::size_of;
use std::{cmp::Ordering, mem::size_of};

use crate::index::PrefixLookupResult;
use crate::{
data,
index::{self, EntryIndex, FAN_LEN},
index::{self, EntryIndex, PrefixLookupResult, FAN_LEN},
};

const N32_SIZE: usize = size_of::<u32>();
Expand Down
8 changes: 5 additions & 3 deletions git-pack/src/multi_index/access.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::cmp::Ordering;
use std::path::{Path, PathBuf};
use std::{
cmp::Ordering,
path::{Path, PathBuf},
};

use crate::index::PrefixLookupResult;
use crate::{
data,
index::PrefixLookupResult,
multi_index::{EntryIndex, File, PackIndex, Version},
};

Expand Down
12 changes: 8 additions & 4 deletions git-pack/tests/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ mod version {

use git_features::progress;
use git_odb::pack;
use git_pack::data::{input, EntryRange};
use git_pack::index;
use git_pack::{
data::{input, EntryRange},
index,
};

use crate::pack::INDEX_V2;
use crate::{fixture_path, pack::V2_PACKS_AND_INDICES};
use crate::{
fixture_path,
pack::{INDEX_V2, V2_PACKS_AND_INDICES},
};

#[test]
fn write_to_stream() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
6 changes: 4 additions & 2 deletions git-pack/tests/pack/multi_index/access.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::multi_index;
use git_testtools::hex_to_id;
use std::path::PathBuf;

use git_testtools::hex_to_id;

use super::multi_index;

#[test]
fn lookup_with_ambiguity() {
let (file, _path) = multi_index();
Expand Down
3 changes: 2 additions & 1 deletion git-repository/src/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ pub mod peel {
PeelReference(#[from] reference::peel::Error),
}
}
use crate::head::Kind;
pub use error::Error;

use crate::head::Kind;

mod peel_to_commit {
use crate::object;

Expand Down
Loading

0 comments on commit 7cf3545

Please sign in to comment.