Skip to content

Commit 527fddf

Browse files
committed
chore: update rust toolchain 1.84
Fixed clippy warnings for lifetime elision and preferring `Display` implementations over `ToString`.
1 parent 41e3f30 commit 527fddf

File tree

20 files changed

+64
-69
lines changed

20 files changed

+64
-69
lines changed

radicle-git-ext/git-ref-format/core/src/cbor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'de: 'a, 'a> Decode<'de> for &'a RefStr {
2424
}
2525
}
2626

27-
impl<'a> Encode for &'a RefStr {
27+
impl Encode for &RefStr {
2828
#[inline]
2929
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
3030
e.str(self.as_str())?;
@@ -54,7 +54,7 @@ impl<'de: 'a, 'a> Decode<'de> for &'a PatternStr {
5454
}
5555
}
5656

57-
impl<'a> Encode for &'a PatternStr {
57+
impl Encode for &PatternStr {
5858
#[inline]
5959
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
6060
e.str(self.as_str())?;
@@ -86,7 +86,7 @@ impl<'de: 'a, 'a> Decode<'de> for Qualified<'a> {
8686
}
8787
}
8888

89-
impl<'a> Encode for Qualified<'a> {
89+
impl Encode for Qualified<'_> {
9090
#[inline]
9191
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
9292
self.as_str().encode(e)
@@ -103,7 +103,7 @@ impl<'de: 'a, 'a> Decode<'de> for Namespaced<'a> {
103103
}
104104
}
105105

106-
impl<'a> Encode for Namespaced<'a> {
106+
impl Encode for Namespaced<'_> {
107107
#[inline]
108108
fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), encode::Error<W::Error>> {
109109
self.as_str().encode(e)

radicle-git-ext/git-ref-format/core/src/name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl AsRef<bstr::BStr> for RefStr {
213213
}
214214
}
215215

216-
impl<'a> AsRef<RefStr> for &'a RefStr {
216+
impl AsRef<RefStr> for &RefStr {
217217
#[inline]
218218
fn as_ref(&self) -> &RefStr {
219219
self

radicle-git-ext/git-ref-format/core/src/name/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<'a> Iterator for Components<'a> {
3434
}
3535
}
3636

37-
impl<'a> DoubleEndedIterator for Components<'a> {
37+
impl DoubleEndedIterator for Components<'_> {
3838
#[inline]
3939
fn next_back(&mut self) -> Option<Self::Item> {
4040
self.inner
@@ -83,7 +83,7 @@ impl<'a> Component<'a> {
8383
}
8484
}
8585

86-
impl<'a> Deref for Component<'a> {
86+
impl Deref for Component<'_> {
8787
type Target = RefStr;
8888

8989
#[inline]

radicle-git-ext/git-ref-format/core/src/refspec/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a> Iterator for Components<'a> {
6666
}
6767
}
6868

69-
impl<'a> DoubleEndedIterator for Components<'a> {
69+
impl DoubleEndedIterator for Components<'_> {
7070
#[inline]
7171
fn next_back(&mut self) -> Option<Self::Item> {
7272
self.inner.next_back().map(|next| match next {

radicle-git-ext/git-ref-format/core/src/serde.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a RefStr {
2323
}
2424
}
2525

26-
impl<'a> Serialize for &'a RefStr {
26+
impl Serialize for &RefStr {
2727
#[inline]
2828
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2929
where
@@ -65,7 +65,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a PatternStr {
6565
}
6666
}
6767

68-
impl<'a> Serialize for &'a PatternStr {
68+
impl Serialize for &PatternStr {
6969
#[inline]
7070
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
7171
where

radicle-git-ext/src/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> From<&'a str> for Branch<'a> {
4747
}
4848
}
4949

50-
impl<'a> From<String> for Branch<'a> {
50+
impl From<String> for Branch<'_> {
5151
fn from(s: String) -> Self {
5252
Self::Name(Cow::Owned(s))
5353
}

radicle-git-ext/src/commit.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
pub mod headers;
1515
pub mod trailers;
1616

17-
use std::{
18-
fmt::Write as _,
19-
str::{self, FromStr},
20-
};
17+
use core::fmt;
18+
use std::str::{self, FromStr};
2119

2220
use git2::{ObjectType, Oid};
2321

@@ -139,7 +137,7 @@ impl<Tree, Parent> CommitData<Tree, Parent> {
139137
}
140138

141139
/// Iterate over the [`Headers`] values that match the provided `name`.
142-
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + '_ {
140+
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a {
143141
self.headers.values(name)
144142
}
145143

@@ -367,32 +365,28 @@ impl FromStr for Commit {
367365
}
368366
}
369367

370-
impl ToString for Commit {
371-
fn to_string(&self) -> String {
372-
let mut buf = String::new();
373-
374-
writeln!(buf, "tree {}", self.tree).ok();
375-
368+
impl fmt::Display for Commit {
369+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
370+
writeln!(f, "tree {}", self.tree)?;
376371
for parent in self.parents() {
377-
writeln!(buf, "parent {parent}").ok();
372+
writeln!(f, "parent {parent}")?;
378373
}
379-
380-
writeln!(buf, "author {}", self.author).ok();
381-
writeln!(buf, "committer {}", self.committer).ok();
374+
writeln!(f, "author {}", self.author)?;
375+
writeln!(f, "committer {}", self.committer)?;
382376

383377
for (name, value) in self.headers.iter() {
384-
writeln!(buf, "{name} {}", value.replace('\n', "\n ")).ok();
378+
writeln!(f, "{name} {}", value.replace('\n', "\n "))?;
385379
}
386-
writeln!(buf).ok();
387-
write!(buf, "{}", self.message.trim()).ok();
388-
writeln!(buf).ok();
380+
writeln!(f)?;
381+
write!(f, "{}", self.message.trim())?;
382+
writeln!(f)?;
389383

390384
if !self.trailers.is_empty() {
391-
writeln!(buf).ok();
385+
writeln!(f)?;
392386
}
393387
for trailer in self.trailers.iter() {
394-
writeln!(buf, "{}", Trailer::from(trailer).display(": ")).ok();
388+
writeln!(f, "{}", Trailer::from(trailer).display(": "))?;
395389
}
396-
buf
390+
Ok(())
397391
}
398392
}

radicle-git-ext/src/commit/headers.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::fmt;
12
use std::borrow::Cow;
23

34
const BEGIN_SSH: &str = "-----BEGIN SSH SIGNATURE-----\n";
@@ -30,17 +31,17 @@ impl<'a> Signature<'a> {
3031
}
3132
}
3233

33-
pub struct UnknownScheme;
34-
35-
impl<'a> ToString for Signature<'a> {
36-
fn to_string(&self) -> String {
34+
impl fmt::Display for Signature<'_> {
35+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3736
match self {
38-
Signature::Pgp(pgp) => pgp.to_string(),
39-
Signature::Ssh(ssh) => ssh.to_string(),
37+
Signature::Pgp(pgp) => f.write_str(pgp.as_ref()),
38+
Signature::Ssh(ssh) => f.write_str(ssh.as_ref()),
4039
}
4140
}
4241
}
4342

43+
pub struct UnknownScheme;
44+
4445
impl Headers {
4546
pub fn new() -> Self {
4647
Headers(Vec::new())
@@ -50,7 +51,7 @@ impl Headers {
5051
self.0.iter().map(|(k, v)| (k.as_str(), v.as_str()))
5152
}
5253

53-
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + '_ {
54+
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a {
5455
self.iter()
5556
.filter_map(move |(k, v)| (k == name).then_some(v))
5657
}

radicle-git-ext/src/commit/trailers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub struct Display<'a> {
148148
separator: &'a str,
149149
}
150150

151-
impl<'a> fmt::Display for Display<'a> {
151+
impl fmt::Display for Display<'_> {
152152
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
153153
write!(
154154
f,

radicle-git-ext/src/oid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod serde_impls {
3535
{
3636
struct OidVisitor;
3737

38-
impl<'de> Visitor<'de> for OidVisitor {
38+
impl Visitor<'_> for OidVisitor {
3939
type Value = Oid;
4040

4141
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {

radicle-surf/src/blob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct BlobRef<'a> {
9999
pub(crate) inner: git2::Blob<'a>,
100100
}
101101

102-
impl<'a> BlobRef<'a> {
102+
impl BlobRef<'_> {
103103
pub fn id(&self) -> Oid {
104104
self.inner.id().into()
105105
}
@@ -149,7 +149,7 @@ where
149149
}
150150

151151
#[cfg(feature = "serde")]
152-
impl<'a> Serialize for BlobRef<'a> {
152+
impl Serialize for BlobRef<'_> {
153153
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
154154
where
155155
S: Serializer,

radicle-surf/src/commit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl std::fmt::Debug for Author {
113113
}
114114
}
115115

116-
impl<'repo> TryFrom<git2::Signature<'repo>> for Author {
116+
impl TryFrom<git2::Signature<'_>> for Author {
117117
type Error = str::Utf8Error;
118118

119119
fn try_from(signature: git2::Signature) -> Result<Self, Self::Error> {
@@ -182,7 +182,7 @@ impl Serialize for Commit {
182182
}
183183
}
184184

185-
impl<'repo> TryFrom<git2::Commit<'repo>> for Commit {
185+
impl TryFrom<git2::Commit<'_>> for Commit {
186186
type Error = Error;
187187

188188
fn try_from(commit: git2::Commit) -> Result<Self, Self::Error> {

radicle-surf/src/diff/git.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub mod error {
9999
}
100100
}
101101

102-
impl<'a> TryFrom<git2::DiffFile<'a>> for DiffFile {
102+
impl TryFrom<git2::DiffFile<'_>> for DiffFile {
103103
type Error = error::FileMode;
104104

105105
fn try_from(value: git2::DiffFile) -> Result<Self, Self::Error> {
@@ -205,7 +205,7 @@ impl TryFrom<git2::Patch<'_>> for DiffContent {
205205
}
206206
}
207207

208-
impl<'a> TryFrom<git2::DiffLine<'a>> for Modification {
208+
impl TryFrom<git2::DiffLine<'_>> for Modification {
209209
type Error = error::Modification;
210210

211211
fn try_from(line: git2::DiffLine) -> Result<Self, Self::Error> {
@@ -228,7 +228,7 @@ impl From<git2::DiffStats> for Stats {
228228
}
229229
}
230230

231-
impl<'a> TryFrom<git2::Diff<'a>> for Diff {
231+
impl TryFrom<git2::Diff<'_>> for Diff {
232232
type Error = error::Diff;
233233

234234
fn try_from(git_diff: git2::Diff) -> Result<Diff, Self::Error> {

radicle-surf/src/history.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a> History<'a> {
7474
}
7575
}
7676

77-
impl<'a> Iterator for History<'a> {
77+
impl Iterator for History<'_> {
7878
type Item = Result<Commit, Error>;
7979

8080
fn next(&mut self) -> Option<Self::Item> {
@@ -108,7 +108,7 @@ impl<'a> Iterator for History<'a> {
108108
}
109109
}
110110

111-
impl<'a> std::fmt::Debug for History<'a> {
111+
impl std::fmt::Debug for History<'_> {
112112
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113113
write!(f, "History of {}", self.head.id)
114114
}

radicle-surf/src/refs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'a> Tags<'a> {
3232
}
3333
}
3434

35-
impl<'a> Iterator for Tags<'a> {
35+
impl Iterator for Tags<'_> {
3636
type Item = Result<Tag, error::Tag>;
3737

3838
fn next(&mut self) -> Option<Self::Item> {
@@ -54,7 +54,7 @@ impl<'a> Iterator for Tags<'a> {
5454
}
5555
}
5656

57-
impl<'a> Iterator for TagNames<'a> {
57+
impl Iterator for TagNames<'_> {
5858
type Item = Result<Qualified<'static>, error::Tag>;
5959

6060
fn next(&mut self) -> Option<Self::Item> {
@@ -99,7 +99,7 @@ impl<'a> Branches<'a> {
9999
}
100100
}
101101

102-
impl<'a> Iterator for Branches<'a> {
102+
impl Iterator for Branches<'_> {
103103
type Item = Result<Branch, error::Branch>;
104104

105105
fn next(&mut self) -> Option<Self::Item> {
@@ -121,7 +121,7 @@ impl<'a> Iterator for Branches<'a> {
121121
}
122122
}
123123

124-
impl<'a> Iterator for BranchNames<'a> {
124+
impl Iterator for BranchNames<'_> {
125125
type Item = Result<Qualified<'static>, error::Branch>;
126126

127127
fn next(&mut self) -> Option<Self::Item> {
@@ -177,7 +177,7 @@ impl<'a> Categories<'a> {
177177
}
178178
}
179179

180-
impl<'a> Iterator for Categories<'a> {
180+
impl Iterator for Categories<'_> {
181181
type Item = Result<(RefString, RefString), error::Category>;
182182

183183
fn next(&mut self) -> Option<Self::Item> {

radicle-surf/t/src/code_browsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn browse_repo_lazily() {
5858
#[test]
5959
fn test_file_history() {
6060
let repo = Repository::open(GIT_PLATINUM).unwrap();
61-
let history = repo.history(&Branch::local(refname!("dev"))).unwrap();
61+
let history = repo.history(Branch::local(refname!("dev"))).unwrap();
6262
let path = Path::new("README.md");
6363
let mut file_history = history.by_path(&path);
6464
let commit = file_history.next().unwrap().unwrap();

radicle-surf/t/src/last_commit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn root() {
101101
.map(|commit| commit.id);
102102

103103
let expected_oid = repo
104-
.history(&Branch::local(refname!("master")))
104+
.history(Branch::local(refname!("master")))
105105
.unwrap()
106106
.head()
107107
.id;
@@ -112,7 +112,7 @@ fn root() {
112112
fn binary_file() {
113113
let repo = Repository::open(GIT_PLATINUM)
114114
.expect("Could not retrieve ./data/git-platinum as git repository");
115-
let history = repo.history(&Branch::local(refname!("dev"))).unwrap();
115+
let history = repo.history(Branch::local(refname!("dev"))).unwrap();
116116
let file_commit = history.by_path(&"bin/cat").next();
117117
assert!(file_commit.is_some());
118118
println!("file commit: {:?}", &file_commit);

0 commit comments

Comments
 (0)