ran `cargo clippy --fix -- -Wclippy::use_self`

pull/909/head
adamnemecek 2025-10-26 12:12:11 +07:00
parent 5df84a4e92
commit 2ec5fe7948
7 changed files with 41 additions and 41 deletions

@ -24,11 +24,11 @@ impl<'b, T> Stack<'b, T> {
self.head.map(|n| &n.val)
}
pub(crate) fn pop(&self) -> Option<Stack<'b, T>> {
pub(crate) fn pop(&self) -> Option<Self> {
self.head.map(|n| Self { head: n.next })
}
pub(crate) fn push(&self, v: T, alloc: &'b Bump) -> Stack<'b, T> {
pub(crate) fn push(&self, v: T, alloc: &'b Bump) -> Self {
Self {
head: Some(alloc.alloc(Node {
val: v,

@ -66,7 +66,7 @@ impl Hunk {
));
}
Hunk {
Self {
novel_lhs: self.novel_lhs.union(&other.novel_lhs).copied().collect(),
novel_rhs: self.novel_rhs.union(&other.novel_rhs).copied().collect(),
lines: deduped_lines,

@ -36,7 +36,7 @@ impl<'f> File<'f> {
language: &'f FileFormat,
path: &'f str,
chunks: Vec<Vec<Line<'f>>>,
) -> File<'f> {
) -> Self {
File {
language,
path,
@ -45,7 +45,7 @@ impl<'f> File<'f> {
}
}
fn with_status(language: &'f FileFormat, path: &'f str, status: Status) -> File<'f> {
fn with_status(language: &'f FileFormat, path: &'f str, status: Status) -> Self {
File {
language,
path,
@ -201,7 +201,7 @@ struct Line<'l> {
}
impl<'l> Line<'l> {
fn new(lhs_number: Option<u32>, rhs_number: Option<u32>) -> Line<'l> {
fn new(lhs_number: Option<u32>, rhs_number: Option<u32>) -> Self {
Line {
lhs: lhs_number.map(Side::new),
rhs: rhs_number.map(Side::new),
@ -216,7 +216,7 @@ struct Side<'s> {
}
impl<'s> Side<'s> {
fn new(line_number: u32) -> Side<'s> {
fn new(line_number: u32) -> Self {
Side {
line_number,
changes: Vec::new(),
@ -259,15 +259,15 @@ impl Highlight {
};
match highlight {
TokenKind::Delimiter => Highlight::Delimiter,
TokenKind::Delimiter => Self::Delimiter,
TokenKind::Atom(atom) => match atom {
AtomKind::String(StringKind::StringLiteral) => Highlight::String,
AtomKind::String(StringKind::Text) => Highlight::Normal,
AtomKind::Keyword => Highlight::Keyword,
AtomKind::Comment => Highlight::Comment,
AtomKind::Type => Highlight::Type,
AtomKind::Normal => Highlight::Normal,
AtomKind::TreeSitterError => Highlight::TreeSitterError,
AtomKind::String(StringKind::StringLiteral) => Self::String,
AtomKind::String(StringKind::Text) => Self::Normal,
AtomKind::Keyword => Self::Keyword,
AtomKind::Comment => Self::Comment,
AtomKind::Type => Self::Type,
AtomKind::Normal => Self::Normal,
AtomKind::TreeSitterError => Self::TreeSitterError,
},
}
}

@ -26,7 +26,7 @@ pub(crate) enum BackgroundColor {
impl BackgroundColor {
pub(crate) fn is_dark(self) -> bool {
matches!(self, BackgroundColor::Dark)
matches!(self, Self::Dark)
}
}

@ -398,7 +398,7 @@ pub(crate) enum FileArgument {
impl FileArgument {
pub(crate) fn permissions(&self) -> Option<FilePermissions> {
match self {
FileArgument::NamedPath(path) => {
Self::NamedPath(path) => {
// When used with `git difftool`, the first argument
// is a temporary file that always has the same
// permissions. That doesn't mean the file permissions
@ -410,8 +410,8 @@ impl FileArgument {
let metadata = std::fs::metadata(path).ok()?;
Some(metadata.permissions().into())
}
FileArgument::Stdin => None,
FileArgument::DevNull => None,
Self::Stdin => None,
Self::DevNull => None,
}
}
}
@ -484,11 +484,11 @@ impl FileArgument {
/// argument.
pub(crate) fn from_cli_argument(arg: &OsStr) -> Self {
if arg == "/dev/null" {
FileArgument::DevNull
Self::DevNull
} else if arg == "-" {
FileArgument::Stdin
Self::Stdin
} else {
FileArgument::NamedPath(PathBuf::from(arg))
Self::NamedPath(PathBuf::from(arg))
}
}
@ -497,9 +497,9 @@ impl FileArgument {
pub(crate) fn from_path_argument(arg: &OsStr) -> Self {
// For new and deleted files, Git passes `/dev/null` as the reference file.
if arg == "/dev/null" {
FileArgument::DevNull
Self::DevNull
} else {
FileArgument::NamedPath(PathBuf::from(arg))
Self::NamedPath(PathBuf::from(arg))
}
}
}
@ -507,11 +507,11 @@ impl FileArgument {
impl Display for FileArgument {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FileArgument::NamedPath(path) => {
Self::NamedPath(path) => {
write!(f, "{}", relative_to_current(path).display())
}
FileArgument::Stdin => write!(f, "(stdin)"),
FileArgument::DevNull => write!(f, "/dev/null"),
Self::Stdin => write!(f, "(stdin)"),
Self::DevNull => write!(f, "/dev/null"),
}
}
}

@ -196,13 +196,13 @@ impl<'a> fmt::Debug for Syntax<'a> {
impl<'a> Syntax<'a> {
pub(crate) fn new_list(
arena: &'a Arena<Syntax<'a>>,
arena: &'a Arena<Self>,
open_content: &str,
open_position: Vec<SingleLineSpan>,
children: Vec<&'a Syntax<'a>>,
children: Vec<&'a Self>,
close_content: &str,
close_position: Vec<SingleLineSpan>,
) -> &'a Syntax<'a> {
) -> &'a Self {
// Skip empty atoms: they aren't displayed, so there's no
// point making our syntax tree bigger. These occur when we're
// parsing incomplete or malformed programs.
@ -249,11 +249,11 @@ impl<'a> Syntax<'a> {
}
pub(crate) fn new_atom(
arena: &'a Arena<Syntax<'a>>,
arena: &'a Arena<Self>,
mut position: Vec<SingleLineSpan>,
mut content: String,
kind: AtomKind,
) -> &'a Syntax<'a> {
) -> &'a Self {
// If a parser hasn't cleaned up \r on CRLF files with
// comments, discard it.
if content.ends_with('\r') {
@ -283,11 +283,11 @@ impl<'a> Syntax<'a> {
}
}
pub(crate) fn parent(&self) -> Option<&'a Syntax<'a>> {
pub(crate) fn parent(&self) -> Option<&'a Self> {
self.info().parent.get()
}
pub(crate) fn next_sibling(&self) -> Option<&'a Syntax<'a>> {
pub(crate) fn next_sibling(&self) -> Option<&'a Self> {
self.info().next_sibling.get()
}
@ -681,9 +681,9 @@ impl MatchKind {
pub(crate) fn is_novel(&self) -> bool {
matches!(
self,
MatchKind::Novel { .. }
| MatchKind::NovelWord { .. }
| MatchKind::UnchangedPartOfNovelItem { .. }
Self::Novel { .. }
| Self::NovelWord { .. }
| Self::UnchangedPartOfNovelItem { .. }
)
}
}

@ -27,10 +27,10 @@ pub(crate) enum FileFormat {
impl Display for FileFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FileFormat::SupportedLanguage(language) => write!(f, "{}", language_name(*language)),
FileFormat::PlainText => write!(f, "Text"),
FileFormat::TextFallback { reason } => write!(f, "Text ({})", reason),
FileFormat::Binary => write!(f, "Binary"),
Self::SupportedLanguage(language) => write!(f, "{}", language_name(*language)),
Self::PlainText => write!(f, "Text"),
Self::TextFallback { reason } => write!(f, "Text ({})", reason),
Self::Binary => write!(f, "Binary"),
}
}
}