Skip to content

Commit 6f009d7

Browse files
committed
thanks clippy
1 parent 8c00e6f commit 6f009d7

File tree

38 files changed

+117
-109
lines changed

38 files changed

+117
-109
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,7 @@ no_effect_underscore_binding = "allow" # x1
377377
empty_docs = "allow"
378378
too_long_first_doc_paragraph = "allow"
379379
large_stack_arrays = "allow"
380+
381+
# Fix one day
382+
result_large_err = "allow"
383+
large_enum_variant = "allow"

gitoxide-core/src/corpus/engine.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ impl Engine {
5757
let repos = self.refresh_repos(&corpus_path, corpus_id)?;
5858
self.state.progress.set_name("refresh repos".into());
5959
self.state.progress.info(format!(
60-
"Added or updated {} repositories under {corpus_path:?}",
61-
repos.len()
60+
"Added or updated {} repositories under '{corpus_path}'",
61+
repos.len(),
62+
corpus_path = corpus_path.display(),
6263
));
6364
Ok(())
6465
}
@@ -316,7 +317,7 @@ impl Engine {
316317
out.push(repo);
317318
progress.inc();
318319
}
319-
Err(err) => progress.fail(format!("{repo_path:?}: {err:#?}")),
320+
Err(err) => progress.fail(format!("{repo_path}: {err:#?}", repo_path = repo_path.display())),
320321
}
321322
}
322323
statement.finalize()?;

gitoxide-core/src/hours/core.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,11 @@ pub fn spawn_tree_delta_threads<'scope>(
166166
(true, true) => {
167167
files.modified += 1;
168168
if let Some(cache) = cache.as_mut() {
169-
let mut diff = change.diff(cache).map_err(|err| {
170-
std::io::Error::new(std::io::ErrorKind::Other, err)
171-
})?;
169+
let mut diff = change.diff(cache).map_err(std::io::Error::other)?;
172170
let mut nl = 0;
173-
if let Some(counts) = diff.line_counts().map_err(|err| {
174-
std::io::Error::new(std::io::ErrorKind::Other, err)
175-
})? {
171+
if let Some(counts) =
172+
diff.line_counts().map_err(std::io::Error::other)?
173+
{
176174
nl += counts.insertions as usize + counts.removals as usize;
177175
lines.added += counts.insertions as usize;
178176
lines.removed += counts.removals as usize;

gitoxide-core/src/organize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ fn handle(
138138

139139
if let Some(parent_repo_path) = find_parent_repo(git_workdir) {
140140
progress.fail(format!(
141-
"Skipping repository at {:?} as it is nested within repository {:?}",
141+
"Skipping repository at '{}' as it is nested within repository '{}'",
142142
git_workdir.display(),
143-
parent_repo_path
143+
parent_repo_path.display()
144144
));
145145
return Ok(());
146146
}
@@ -157,7 +157,7 @@ fn handle(
157157
};
158158
if url.path.is_empty() {
159159
progress.info(format!(
160-
"Skipping repository at {:?} whose remote does not have a path: {:?}",
160+
"Skipping repository at '{}' whose remote does not have a path: {}",
161161
git_workdir.display(),
162162
url.to_bstring()
163163
));

gitoxide-core/src/pack/receive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn receive_pack_blocking(
294294
None::<gix::objs::find::Never>,
295295
options,
296296
)
297-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
297+
.map_err(io::Error::other)?;
298298

299299
if let Some(directory) = refs_directory.take() {
300300
write_raw_refs(refs, directory)?;

gitoxide-core/src/query/db.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ pub fn create(path: impl AsRef<std::path::Path>) -> anyhow::Result<rusqlite::Con
1919
}
2020
Some(version) if version != VERSION => match con.close() {
2121
Ok(()) => {
22-
std::fs::remove_file(path)
23-
.with_context(|| format!("Failed to remove incompatible database file at {path:?}"))?;
22+
std::fs::remove_file(path).with_context(|| {
23+
format!(
24+
"Failed to remove incompatible database file at {path}",
25+
path = path.display()
26+
)
27+
})?;
2428
con = rusqlite::Connection::open(path)?;
2529
con.execute_batch(meta_table)?;
2630
con.execute("INSERT into meta(version) values(?)", params![VERSION])?;

gitoxide-core/src/repository/attributes/validate_baseline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ pub(crate) mod function {
4444
if repo.is_bare() {
4545
writeln!(
4646
err,
47-
"Repo {:?} is bare - disabling git-ignore baseline as `git check-ignore` needs a worktree",
48-
repo.path()
47+
"Repo at '{repo}' is bare - disabling git-ignore baseline as `git check-ignore` needs a worktree",
48+
repo = repo.path().display()
4949
)
5050
.ok();
5151
ignore = false;

gitoxide-core/src/repository/fetch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub(crate) mod function {
169169

170170
let start = std::time::Instant::now();
171171
progress.set_name("layout graph".into());
172-
progress.info(format!("writing {path:?}…"));
172+
progress.info(format!("writing {}…", path.display()));
173173
let mut svg = SVGWriter::new();
174174
vg.do_it(false, false, false, &mut svg);
175175
std::fs::write(path, svg.finalize().as_bytes())?;

gitoxide-core/src/repository/revision/list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub(crate) mod function {
117117
if let Some((mut vg, path, _)) = vg {
118118
let start = std::time::Instant::now();
119119
progress.set_name("layout graph".into());
120-
progress.info(format!("writing {path:?}…"));
120+
progress.info(format!("writing {}…", path.display()));
121121
let mut svg = SVGWriter::new();
122122
vg.do_it(false, false, false, &mut svg);
123123
std::fs::write(&path, svg.finalize().as_bytes())?;

gix-config/tests/config/file/init/from_paths/includes/conditional/gitdir/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub fn assert_section_value(
142142
Some(Value::Override) => Some(cow_str("override-value")),
143143
None => None,
144144
},
145-
"gix-config disagrees with the expected value, {:?} for debugging",
146-
env.tempdir.into_path()
145+
"gix-config disagrees with the expected value, {} for debugging",
146+
env.tempdir.into_path().display()
147147
);
148148
assure_git_agrees(expected, env)
149149
}
@@ -171,9 +171,9 @@ fn assure_git_agrees(expected: Option<Value>, env: GitEnv) -> crate::Result {
171171
assert_eq!(
172172
output.status.success(),
173173
expected.is_some(),
174-
"{:?}, {:?} for debugging",
174+
"{:?}, {} for debugging",
175175
output,
176-
env.tempdir.into_path()
176+
env.tempdir.into_path().display()
177177
);
178178
let git_output: BString = output.stdout.trim_end().into();
179179
assert_eq!(

gix-config/tests/config/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::unnecessary_debug_formatting)]
12
pub use gix_testtools::Result;
23

34
mod file;

gix-date/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use parse::function::parse;
1717
pub use parse::function::parse_header;
1818

1919
/// A timestamp with timezone.
20-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
20+
#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
2121
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2222
pub struct Time {
2323
/// The seconds that have passed since UNIX epoch. This makes it UTC, or `<seconds>+0000`.

gix-date/src/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub(crate) mod function {
218218
Ok(s) => s,
219219
Err(_err) => {
220220
// Inefficient, but it's not the common case.
221-
let first_digits: String = seconds.chars().take_while(|b| b.is_ascii_digit()).collect();
221+
let first_digits: String = seconds.chars().take_while(char::is_ascii_digit).collect();
222222
first_digits.parse().ok()?
223223
}
224224
};

gix-date/src/time/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,3 @@ impl From<CustomFormat> for Format {
4040
pub mod format;
4141
mod init;
4242
mod write;
43-
44-
mod impls {
45-
use crate::Time;
46-
47-
impl Default for Time {
48-
fn default() -> Self {
49-
Time { seconds: 0, offset: 0 }
50-
}
51-
}
52-
}

gix-features/src/zlib/stream/deflate/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod deflate_stream {
4545
let r = InflateReader::from_read(io::BufReader::new(std::fs::File::open(fixture_path(
4646
"objects/37/d4e6c5c48ba0d245164c4e10d5f41140cab980",
4747
))?));
48+
#[allow(clippy::unbuffered_bytes)]
4849
let mut bytes = r.bytes();
4950
let content = bytes.by_ref().take(16).collect::<Result<Vec<_>, _>>()?;
5051
assert_eq!(content.as_slice().as_bstr(), b"blob 9\0hi there\n".as_bstr());

gix-fs/src/dir/create.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ mod error {
6363
retries,
6464
} => write!(
6565
f,
66-
"Permanently failing to create directory {dir:?} ({retries_left:?} of {retries:?})",
66+
"Permanently failing to create directory '{dir}' ({retries_left:?} of {retries:?})",
67+
dir = dir.display(),
6768
),
6869
}
6970
}

gix-fs/src/dir/remove.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ impl<'a> Iter<'a> {
2020
if !target.starts_with(boundary) {
2121
return Err(std::io::Error::new(
2222
std::io::ErrorKind::InvalidInput,
23-
format!("Removal target {target:?} must be contained in boundary {boundary:?}"),
23+
format!(
24+
"Removal target '{target}' must be contained in boundary '{boundary}'",
25+
target = target.display(),
26+
boundary = boundary.display()
27+
),
2428
));
2529
}
2630
let cursor = if target == boundary {
@@ -93,7 +97,7 @@ pub fn empty_depth_first(delete_dir: PathBuf) -> std::io::Result<()> {
9397
if entry.file_type()?.is_dir() {
9498
next_to_push.push(entry.path());
9599
} else {
96-
return Err(std::io::Error::new(std::io::ErrorKind::Other, "Directory not empty"));
100+
return Err(std::io::Error::other("Directory not empty"));
97101
}
98102
}
99103
if num_entries == 0 {

gix-fs/src/stack.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ impl Stack {
156156
) -> std::io::Result<()> {
157157
let mut components = relative.to_normal_path_components().peekable();
158158
if self.valid_components != 0 && components.peek().is_none() {
159-
return Err(std::io::Error::new(
160-
std::io::ErrorKind::Other,
161-
"empty inputs are not allowed",
162-
));
159+
return Err(std::io::Error::other("empty inputs are not allowed"));
163160
}
164161
if self.valid_components == 0 {
165162
delegate.push_directory(self)?;

gix-index/src/extension/end_of_index_entry/decode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn decode(data: &[u8], object_hash: gix_hash::Kind) -> Result<Option<usize>,
4848
return Ok(None);
4949
}
5050
// The last-to-this chunk ends where ours starts
51-
if last_chunk.map_or(true, |s| s.as_ptr_range().end != (&data[start_of_eoie]) as *const _) {
51+
if last_chunk.map_or(true, |s| !std::ptr::eq(s.as_ptr_range().end, &data[start_of_eoie])) {
5252
return Ok(None);
5353
}
5454

gix-odb/src/store_impls/dynamic/load_index.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl super::Store {
165165
}
166166
if previous_state_id == index.state_id() {
167167
let potentially_new_index = self.index.load();
168-
if Arc::as_ptr(&potentially_new_index) == Arc::as_ptr(&index) {
168+
if std::ptr::eq(Arc::as_ptr(&potentially_new_index), Arc::as_ptr(&index)) {
169169
// There isn't a new index with which to retry the whole ordeal, so nothing could be done here.
170170
return false;
171171
} else {
@@ -392,9 +392,11 @@ impl super::Store {
392392
next_index_to_load: index_unchanged
393393
.then(|| Arc::clone(&index.next_index_to_load))
394394
.unwrap_or_default(),
395-
loaded_indices: index_unchanged
396-
.then(|| Arc::clone(&index.loaded_indices))
397-
.unwrap_or_else(|| Arc::new(num_loaded_indices.into())),
395+
loaded_indices: if index_unchanged {
396+
Arc::clone(&index.loaded_indices)
397+
} else {
398+
Arc::new(num_loaded_indices.into())
399+
},
398400
num_indices_currently_being_loaded: Default::default(),
399401
});
400402
self.index.store(new_index);

gix-prompt/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ pub fn ask(prompt: &str, opts: &Options<'_>) -> Result<String, Error> {
4343
return Ok(stdout);
4444
}
4545
}
46-
Err(err) => eprintln!("Cannot run askpass program: {askpass:?} with error: {err}"),
46+
Err(err) => eprintln!(
47+
"Cannot run askpass program: '{askpass}' with error: {err}",
48+
askpass = askpass.display()
49+
),
4750
}
4851
}
4952
imp::ask(prompt, opts)

gix-status/src/index_as_worktree/function.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ where
575575
},
576576
&mut |buf| Ok(self.objects.find_blob(self.id, buf).map(|_| Some(()))?),
577577
)
578-
.map_err(|err| Error::Io(io::Error::new(io::ErrorKind::Other, err).into()))?;
578+
.map_err(|err| Error::Io(io::Error::other(err).into()))?;
579579
let len = match out {
580580
ToGitOutcome::Unchanged(_) => Some(self.file_len),
581581
ToGitOutcome::Process(_) | ToGitOutcome::Buffer(_) => None,

gix-status/src/stack.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ impl gix_fs::stack::Delegate for Delegate {
6666
}
6767

6868
if stack.current().symlink_metadata()?.is_symlink() {
69-
return Err(std::io::Error::new(
70-
std::io::ErrorKind::Other,
71-
"Cannot step through symlink to perform an lstat",
72-
));
69+
return Err(std::io::Error::other("Cannot step through symlink to perform an lstat"));
7370
}
7471
Ok(())
7572
}

gix-submodule/src/access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl File {
181181
.sections_by_name("submodule")
182182
.into_iter()
183183
.flatten()
184-
.any(|s| (s.header().subsection_name() == Some(name) && s.meta() as *const _ != ours as *const _));
184+
.any(|s| (s.header().subsection_name() == Some(name) && !std::ptr::eq(s.meta(), ours)));
185185
if !has_value_from_foreign_section {
186186
return Err(config::update::Error::CommandForbiddenInModulesConfiguration {
187187
submodule: name.to_owned(),

gix-worktree-state/tests/state/checkout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static DRIVER: Lazy<PathBuf> = Lazy::new(|| {
3030
.join("debug")
3131
.join("examples")
3232
.join(if cfg!(windows) { "arrow.exe" } else { "arrow" });
33-
assert!(path.is_file(), "Expecting driver to be located at {path:?}");
33+
assert!(path.is_file(), "Expecting driver to be located at {}", path.display());
3434
path
3535
});
3636

gix-worktree-stream/tests/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ mod from_tree {
295295
.join("debug")
296296
.join("examples")
297297
.join(if cfg!(windows) { "arrow.exe" } else { "arrow" });
298-
assert!(path.is_file(), "Expecting driver to be located at {path:?}");
298+
assert!(path.is_file(), "Expecting driver to be located at {}", path.display());
299299
path
300300
});
301301

gix-worktree/src/stack/delegate.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,12 @@ fn validate_last_component(
135135
let Some(last_component) = stack.current_relative().components().next_back() else {
136136
return Ok(());
137137
};
138-
let last_component =
139-
gix_path::try_into_bstr(std::borrow::Cow::Borrowed(last_component.as_os_str().as_ref())).map_err(|_err| {
140-
std::io::Error::new(
141-
std::io::ErrorKind::Other,
142-
format!(
143-
"Path component {last_component:?} of path \"{}\" contained invalid UTF-8 and could not be validated",
144-
stack.current_relative().display()
145-
),
146-
)
138+
let last_component = gix_path::try_into_bstr(std::borrow::Cow::Borrowed(last_component.as_os_str().as_ref()))
139+
.map_err(|_err| {
140+
std::io::Error::other(format!(
141+
"Path component {last_component:?} of path \"{}\" contained invalid UTF-8 and could not be validated",
142+
stack.current_relative().display()
143+
))
147144
})?;
148145

149146
if let Err(err) = gix_validate::path::component(
@@ -153,7 +150,7 @@ fn validate_last_component(
153150
}),
154151
opts,
155152
) {
156-
return Err(std::io::Error::new(std::io::ErrorKind::Other, err));
153+
return Err(std::io::Error::other(err));
157154
}
158155
Ok(())
159156
}

gix-worktree/src/stack/state/attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl Attributes {
110110
if let Ok(idx) = attr_file_in_index {
111111
let blob = objects
112112
.find_blob(&id_mappings[idx].1, buf)
113-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
113+
.map_err(std::io::Error::other)?;
114114
let attr_path = gix_path::from_bstring(attr_path_relative.into_owned());
115115
self.stack.add_patterns_buffer(
116116
blob.data,
@@ -149,7 +149,7 @@ impl Attributes {
149149
if let Some(idx) = attr_file_in_index.ok().filter(|_| !added) {
150150
let blob = objects
151151
.find_blob(&id_mappings[idx].1, buf)
152-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
152+
.map_err(std::io::Error::other)?;
153153
let attr_path = gix_path::from_bstring(attr_path_relative.into_owned());
154154
self.stack.add_patterns_buffer(
155155
blob.data,

gix-worktree/src/stack/state/ignore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Ignore {
180180
Ok(idx) => {
181181
let ignore_blob = objects
182182
.find_blob(&id_mappings[idx].1, buf)
183-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
183+
.map_err(std::io::Error::other)?;
184184
let ignore_path = gix_path::from_bstring(ignore_path_relative.into_owned());
185185
self.stack
186186
.add_patterns_buffer(ignore_blob.data, ignore_path, Some(Path::new("")));
@@ -208,7 +208,7 @@ impl Ignore {
208208
Ok(idx) => {
209209
let ignore_blob = objects
210210
.find_blob(&id_mappings[idx].1, buf)
211-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
211+
.map_err(std::io::Error::other)?;
212212
let ignore_path = gix_path::from_bstring(ignore_path_relative.into_owned());
213213
self.stack
214214
.add_patterns_buffer(ignore_blob.data, ignore_path, Some(Path::new("")));

0 commit comments

Comments
 (0)