Skip to content

Commit 2ec5fe7

Browse files
committed
ran cargo clippy --fix -- -Wclippy::use_self
1 parent 5df84a4 commit 2ec5fe7

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

src/diff/stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ impl<'b, T> Stack<'b, T> {
2424
self.head.map(|n| &n.val)
2525
}
2626

27-
pub(crate) fn pop(&self) -> Option<Stack<'b, T>> {
27+
pub(crate) fn pop(&self) -> Option<Self> {
2828
self.head.map(|n| Self { head: n.next })
2929
}
3030

31-
pub(crate) fn push(&self, v: T, alloc: &'b Bump) -> Stack<'b, T> {
31+
pub(crate) fn push(&self, v: T, alloc: &'b Bump) -> Self {
3232
Self {
3333
head: Some(alloc.alloc(Node {
3434
val: v,

src/display/hunks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Hunk {
6666
));
6767
}
6868

69-
Hunk {
69+
Self {
7070
novel_lhs: self.novel_lhs.union(&other.novel_lhs).copied().collect(),
7171
novel_rhs: self.novel_rhs.union(&other.novel_rhs).copied().collect(),
7272
lines: deduped_lines,

src/display/json.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'f> File<'f> {
3636
language: &'f FileFormat,
3737
path: &'f str,
3838
chunks: Vec<Vec<Line<'f>>>,
39-
) -> File<'f> {
39+
) -> Self {
4040
File {
4141
language,
4242
path,
@@ -45,7 +45,7 @@ impl<'f> File<'f> {
4545
}
4646
}
4747

48-
fn with_status(language: &'f FileFormat, path: &'f str, status: Status) -> File<'f> {
48+
fn with_status(language: &'f FileFormat, path: &'f str, status: Status) -> Self {
4949
File {
5050
language,
5151
path,
@@ -201,7 +201,7 @@ struct Line<'l> {
201201
}
202202

203203
impl<'l> Line<'l> {
204-
fn new(lhs_number: Option<u32>, rhs_number: Option<u32>) -> Line<'l> {
204+
fn new(lhs_number: Option<u32>, rhs_number: Option<u32>) -> Self {
205205
Line {
206206
lhs: lhs_number.map(Side::new),
207207
rhs: rhs_number.map(Side::new),
@@ -216,7 +216,7 @@ struct Side<'s> {
216216
}
217217

218218
impl<'s> Side<'s> {
219-
fn new(line_number: u32) -> Side<'s> {
219+
fn new(line_number: u32) -> Self {
220220
Side {
221221
line_number,
222222
changes: Vec::new(),
@@ -259,15 +259,15 @@ impl Highlight {
259259
};
260260

261261
match highlight {
262-
TokenKind::Delimiter => Highlight::Delimiter,
262+
TokenKind::Delimiter => Self::Delimiter,
263263
TokenKind::Atom(atom) => match atom {
264-
AtomKind::String(StringKind::StringLiteral) => Highlight::String,
265-
AtomKind::String(StringKind::Text) => Highlight::Normal,
266-
AtomKind::Keyword => Highlight::Keyword,
267-
AtomKind::Comment => Highlight::Comment,
268-
AtomKind::Type => Highlight::Type,
269-
AtomKind::Normal => Highlight::Normal,
270-
AtomKind::TreeSitterError => Highlight::TreeSitterError,
264+
AtomKind::String(StringKind::StringLiteral) => Self::String,
265+
AtomKind::String(StringKind::Text) => Self::Normal,
266+
AtomKind::Keyword => Self::Keyword,
267+
AtomKind::Comment => Self::Comment,
268+
AtomKind::Type => Self::Type,
269+
AtomKind::Normal => Self::Normal,
270+
AtomKind::TreeSitterError => Self::TreeSitterError,
271271
},
272272
}
273273
}

src/display/style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) enum BackgroundColor {
2626

2727
impl BackgroundColor {
2828
pub(crate) fn is_dark(self) -> bool {
29-
matches!(self, BackgroundColor::Dark)
29+
matches!(self, Self::Dark)
3030
}
3131
}
3232

src/options.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ pub(crate) enum FileArgument {
398398
impl FileArgument {
399399
pub(crate) fn permissions(&self) -> Option<FilePermissions> {
400400
match self {
401-
FileArgument::NamedPath(path) => {
401+
Self::NamedPath(path) => {
402402
// When used with `git difftool`, the first argument
403403
// is a temporary file that always has the same
404404
// permissions. That doesn't mean the file permissions
@@ -410,8 +410,8 @@ impl FileArgument {
410410
let metadata = std::fs::metadata(path).ok()?;
411411
Some(metadata.permissions().into())
412412
}
413-
FileArgument::Stdin => None,
414-
FileArgument::DevNull => None,
413+
Self::Stdin => None,
414+
Self::DevNull => None,
415415
}
416416
}
417417
}
@@ -484,11 +484,11 @@ impl FileArgument {
484484
/// argument.
485485
pub(crate) fn from_cli_argument(arg: &OsStr) -> Self {
486486
if arg == "/dev/null" {
487-
FileArgument::DevNull
487+
Self::DevNull
488488
} else if arg == "-" {
489-
FileArgument::Stdin
489+
Self::Stdin
490490
} else {
491-
FileArgument::NamedPath(PathBuf::from(arg))
491+
Self::NamedPath(PathBuf::from(arg))
492492
}
493493
}
494494

@@ -497,21 +497,21 @@ impl FileArgument {
497497
pub(crate) fn from_path_argument(arg: &OsStr) -> Self {
498498
// For new and deleted files, Git passes `/dev/null` as the reference file.
499499
if arg == "/dev/null" {
500-
FileArgument::DevNull
500+
Self::DevNull
501501
} else {
502-
FileArgument::NamedPath(PathBuf::from(arg))
502+
Self::NamedPath(PathBuf::from(arg))
503503
}
504504
}
505505
}
506506

507507
impl Display for FileArgument {
508508
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
509509
match self {
510-
FileArgument::NamedPath(path) => {
510+
Self::NamedPath(path) => {
511511
write!(f, "{}", relative_to_current(path).display())
512512
}
513-
FileArgument::Stdin => write!(f, "(stdin)"),
514-
FileArgument::DevNull => write!(f, "/dev/null"),
513+
Self::Stdin => write!(f, "(stdin)"),
514+
Self::DevNull => write!(f, "/dev/null"),
515515
}
516516
}
517517
}

src/parse/syntax.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ impl<'a> fmt::Debug for Syntax<'a> {
196196

197197
impl<'a> Syntax<'a> {
198198
pub(crate) fn new_list(
199-
arena: &'a Arena<Syntax<'a>>,
199+
arena: &'a Arena<Self>,
200200
open_content: &str,
201201
open_position: Vec<SingleLineSpan>,
202-
children: Vec<&'a Syntax<'a>>,
202+
children: Vec<&'a Self>,
203203
close_content: &str,
204204
close_position: Vec<SingleLineSpan>,
205-
) -> &'a Syntax<'a> {
205+
) -> &'a Self {
206206
// Skip empty atoms: they aren't displayed, so there's no
207207
// point making our syntax tree bigger. These occur when we're
208208
// parsing incomplete or malformed programs.
@@ -249,11 +249,11 @@ impl<'a> Syntax<'a> {
249249
}
250250

251251
pub(crate) fn new_atom(
252-
arena: &'a Arena<Syntax<'a>>,
252+
arena: &'a Arena<Self>,
253253
mut position: Vec<SingleLineSpan>,
254254
mut content: String,
255255
kind: AtomKind,
256-
) -> &'a Syntax<'a> {
256+
) -> &'a Self {
257257
// If a parser hasn't cleaned up \r on CRLF files with
258258
// comments, discard it.
259259
if content.ends_with('\r') {
@@ -283,11 +283,11 @@ impl<'a> Syntax<'a> {
283283
}
284284
}
285285

286-
pub(crate) fn parent(&self) -> Option<&'a Syntax<'a>> {
286+
pub(crate) fn parent(&self) -> Option<&'a Self> {
287287
self.info().parent.get()
288288
}
289289

290-
pub(crate) fn next_sibling(&self) -> Option<&'a Syntax<'a>> {
290+
pub(crate) fn next_sibling(&self) -> Option<&'a Self> {
291291
self.info().next_sibling.get()
292292
}
293293

@@ -681,9 +681,9 @@ impl MatchKind {
681681
pub(crate) fn is_novel(&self) -> bool {
682682
matches!(
683683
self,
684-
MatchKind::Novel { .. }
685-
| MatchKind::NovelWord { .. }
686-
| MatchKind::UnchangedPartOfNovelItem { .. }
684+
Self::Novel { .. }
685+
| Self::NovelWord { .. }
686+
| Self::UnchangedPartOfNovelItem { .. }
687687
)
688688
}
689689
}

src/summary.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ pub(crate) enum FileFormat {
2727
impl Display for FileFormat {
2828
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2929
match self {
30-
FileFormat::SupportedLanguage(language) => write!(f, "{}", language_name(*language)),
31-
FileFormat::PlainText => write!(f, "Text"),
32-
FileFormat::TextFallback { reason } => write!(f, "Text ({})", reason),
33-
FileFormat::Binary => write!(f, "Binary"),
30+
Self::SupportedLanguage(language) => write!(f, "{}", language_name(*language)),
31+
Self::PlainText => write!(f, "Text"),
32+
Self::TextFallback { reason } => write!(f, "Text ({})", reason),
33+
Self::Binary => write!(f, "Binary"),
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)