Skip to content

Commit b89672b

Browse files
committed
rust 1.80 clippy fixes
1 parent ce923e6 commit b89672b

38 files changed

+158
-205
lines changed

asyncgit/src/asyncjob/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
9292
}
9393

9494
/// makes sure `next` is cleared and returns `true` if it actually canceled something
95-
pub fn cancel(&mut self) -> bool {
95+
pub fn cancel(&self) -> bool {
9696
if let Ok(mut next) = self.next.lock() {
9797
if next.is_some() {
9898
*next = None;
@@ -111,7 +111,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
111111
/// spawns `task` if nothing is running currently,
112112
/// otherwise schedules as `next` overwriting if `next` was set before.
113113
/// return `true` if the new task gets started right away.
114-
pub fn spawn(&mut self, task: J) -> bool {
114+
pub fn spawn(&self, task: J) -> bool {
115115
self.schedule_next(task);
116116
self.check_for_job()
117117
}
@@ -162,7 +162,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
162162
Ok(())
163163
}
164164

165-
fn schedule_next(&mut self, task: J) {
165+
fn schedule_next(&self, task: J) {
166166
if let Ok(mut next) = self.next.lock() {
167167
*next = Some(task);
168168
}
@@ -226,7 +226,7 @@ mod test {
226226
fn test_overwrite() {
227227
let (sender, receiver) = unbounded();
228228

229-
let mut job: AsyncSingleJob<TestJob> =
229+
let job: AsyncSingleJob<TestJob> =
230230
AsyncSingleJob::new(sender);
231231

232232
let task = TestJob {
@@ -265,7 +265,7 @@ mod test {
265265
fn test_cancel() {
266266
let (sender, receiver) = unbounded();
267267

268-
let mut job: AsyncSingleJob<TestJob> =
268+
let job: AsyncSingleJob<TestJob> =
269269
AsyncSingleJob::new(sender);
270270

271271
let task = TestJob {

asyncgit/src/blame.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ impl AsyncBlame {
5555
}
5656

5757
///
58-
pub fn last(
59-
&mut self,
60-
) -> Result<Option<(BlameParams, FileBlame)>> {
58+
pub fn last(&self) -> Result<Option<(BlameParams, FileBlame)>> {
6159
let last = self.last.lock()?;
6260

6361
Ok(last.clone().map(|last_result| {
@@ -66,7 +64,7 @@ impl AsyncBlame {
6664
}
6765

6866
///
69-
pub fn refresh(&mut self) -> Result<()> {
67+
pub fn refresh(&self) -> Result<()> {
7068
if let Ok(Some(param)) = self.get_last_param() {
7169
self.clear_current()?;
7270
self.request(param)?;
@@ -81,7 +79,7 @@ impl AsyncBlame {
8179

8280
///
8381
pub fn request(
84-
&mut self,
82+
&self,
8583
params: BlameParams,
8684
) -> Result<Option<FileBlame>> {
8785
log::trace!("request");
@@ -181,7 +179,7 @@ impl AsyncBlame {
181179
.map(|last_result| last_result.params))
182180
}
183181

184-
fn clear_current(&mut self) -> Result<()> {
182+
fn clear_current(&self) -> Result<()> {
185183
let mut current = self.current.lock()?;
186184
current.0 = 0;
187185
current.1 = None;

asyncgit/src/commit_files.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl AsyncCommitFiles {
7070

7171
///
7272
pub fn current(
73-
&mut self,
73+
&self,
7474
) -> Result<Option<(CommitFilesParams, ResultType)>> {
7575
let c = self.current.lock()?;
7676

@@ -84,7 +84,7 @@ impl AsyncCommitFiles {
8484
}
8585

8686
///
87-
pub fn fetch(&mut self, params: CommitFilesParams) -> Result<()> {
87+
pub fn fetch(&self, params: CommitFilesParams) -> Result<()> {
8888
if self.is_pending() {
8989
return Ok(());
9090
}

asyncgit/src/diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ impl AsyncDiff {
7373
}
7474

7575
///
76-
pub fn last(&mut self) -> Result<Option<(DiffParams, FileDiff)>> {
76+
pub fn last(&self) -> Result<Option<(DiffParams, FileDiff)>> {
7777
let last = self.last.lock()?;
7878

7979
Ok(last.clone().map(|res| (res.params, res.result)))
8080
}
8181

8282
///
83-
pub fn refresh(&mut self) -> Result<()> {
83+
pub fn refresh(&self) -> Result<()> {
8484
if let Ok(Some(param)) = self.get_last_param() {
8585
self.clear_current()?;
8686
self.request(param)?;
@@ -95,7 +95,7 @@ impl AsyncDiff {
9595

9696
///
9797
pub fn request(
98-
&mut self,
98+
&self,
9999
params: DiffParams,
100100
) -> Result<Option<FileDiff>> {
101101
log::trace!("request {:?}", params);
@@ -212,7 +212,7 @@ impl AsyncDiff {
212212
Ok(self.last.lock()?.clone().map(|e| e.params))
213213
}
214214

215-
fn clear_current(&mut self) -> Result<()> {
215+
fn clear_current(&self) -> Result<()> {
216216
let mut current = self.current.lock()?;
217217
current.0 = 0;
218218
current.1 = None;

asyncgit/src/pull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl AsyncPull {
7171
}
7272

7373
///
74-
pub fn request(&mut self, params: FetchRequest) -> Result<()> {
74+
pub fn request(&self, params: FetchRequest) -> Result<()> {
7575
log::trace!("request");
7676

7777
if self.is_pending()? {

asyncgit/src/push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl AsyncPush {
7878
}
7979

8080
///
81-
pub fn request(&mut self, params: PushRequest) -> Result<()> {
81+
pub fn request(&self, params: PushRequest) -> Result<()> {
8282
log::trace!("request");
8383

8484
if self.is_pending()? {

asyncgit/src/push_tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl AsyncPushTags {
6969
}
7070

7171
///
72-
pub fn request(&mut self, params: PushTagsRequest) -> Result<()> {
72+
pub fn request(&self, params: PushTagsRequest) -> Result<()> {
7373
log::trace!("request");
7474

7575
if self.is_pending()? {

asyncgit/src/revlog.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl AsyncLog {
126126
}
127127

128128
///
129-
pub fn set_background(&mut self) {
129+
pub fn set_background(&self) {
130130
self.background.store(true, Ordering::Relaxed);
131131
}
132132

@@ -146,7 +146,7 @@ impl AsyncLog {
146146
}
147147

148148
///
149-
pub fn fetch(&mut self) -> Result<FetchStatus> {
149+
pub fn fetch(&self) -> Result<FetchStatus> {
150150
self.background.store(false, Ordering::Relaxed);
151151

152152
if self.is_pending() {
@@ -308,7 +308,7 @@ impl AsyncLog {
308308
Ok(())
309309
}
310310

311-
fn clear(&mut self) -> Result<()> {
311+
fn clear(&self) -> Result<()> {
312312
self.current.lock()?.commits.clear();
313313
*self.current_head.lock()? = None;
314314
self.partial_extract.store(false, Ordering::Relaxed);

asyncgit/src/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl AsyncStatus {
7777
}
7878

7979
///
80-
pub fn last(&mut self) -> Result<Status> {
80+
pub fn last(&self) -> Result<Status> {
8181
let last = self.last.lock()?;
8282
Ok(last.clone())
8383
}
@@ -89,7 +89,7 @@ impl AsyncStatus {
8989

9090
///
9191
pub fn fetch(
92-
&mut self,
92+
&self,
9393
params: &StatusParams,
9494
) -> Result<Option<Status>> {
9595
if self.is_pending() {

asyncgit/src/sync/blame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ mod tests {
167167
let repo_path: &RepoPath =
168168
&root.as_os_str().to_str().unwrap().into();
169169

170-
assert!(matches!(blame_file(repo_path, "foo", None), Err(_)));
170+
assert!(blame_file(repo_path, "foo", None).is_err());
171171

172172
File::create(root.join(file_path))?.write_all(b"line 1\n")?;
173173

0 commit comments

Comments
 (0)