Fix clippy::needless_borrow lint violations (#36444)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-18 23:54:35 +02:00 committed by GitHub
parent eecf142f06
commit 9e0e233319
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
242 changed files with 801 additions and 821 deletions

View file

@ -145,7 +145,7 @@ impl Anchor {
.map(|diff| diff.base_text())
{
if a.buffer_id == Some(base_text.remote_id()) {
return a.bias_right(&base_text);
return a.bias_right(base_text);
}
}
a
@ -212,7 +212,7 @@ impl AnchorRangeExt for Range<Anchor> {
}
fn includes(&self, other: &Range<Anchor>, buffer: &MultiBufferSnapshot) -> bool {
self.start.cmp(&other.start, &buffer).is_le() && other.end.cmp(&self.end, &buffer).is_le()
self.start.cmp(&other.start, buffer).is_le() && other.end.cmp(&self.end, buffer).is_le()
}
fn overlaps(&self, other: &Range<Anchor>, buffer: &MultiBufferSnapshot) -> bool {

View file

@ -1686,7 +1686,7 @@ impl MultiBuffer {
cx: &mut Context<Self>,
) -> (Vec<Range<Anchor>>, bool) {
let (excerpt_ids, added_a_new_excerpt) =
self.update_path_excerpts(path, buffer, &buffer_snapshot, new, cx);
self.update_path_excerpts(path, buffer, buffer_snapshot, new, cx);
let mut result = Vec::new();
let mut ranges = ranges.into_iter();
@ -1784,7 +1784,7 @@ impl MultiBuffer {
}
Some((
*existing_id,
excerpt.range.context.to_point(&buffer_snapshot),
excerpt.range.context.to_point(buffer_snapshot),
))
} else {
None
@ -3056,7 +3056,7 @@ impl MultiBuffer {
snapshot.has_conflict = has_conflict;
for (id, diff) in self.diffs.iter() {
if snapshot.diffs.get(&id).is_none() {
if snapshot.diffs.get(id).is_none() {
snapshot.diffs.insert(*id, diff.diff.read(cx).snapshot(cx));
}
}
@ -3177,7 +3177,7 @@ impl MultiBuffer {
&mut new_diff_transforms,
&mut end_of_current_insert,
&mut old_expanded_hunks,
&snapshot,
snapshot,
change_kind,
);
@ -3223,7 +3223,7 @@ impl MultiBuffer {
old_expanded_hunks.clear();
self.push_buffer_content_transform(
&snapshot,
snapshot,
&mut new_diff_transforms,
excerpt_offset,
end_of_current_insert,
@ -3916,8 +3916,8 @@ impl MultiBufferSnapshot {
&self,
range: Range<T>,
) -> Vec<(&BufferSnapshot, Range<usize>, ExcerptId)> {
let start = range.start.to_offset(&self);
let end = range.end.to_offset(&self);
let start = range.start.to_offset(self);
let end = range.end.to_offset(self);
let mut cursor = self.cursor::<usize>();
cursor.seek(&start);
@ -3955,8 +3955,8 @@ impl MultiBufferSnapshot {
&self,
range: Range<T>,
) -> impl Iterator<Item = (&BufferSnapshot, Range<usize>, ExcerptId, Option<Anchor>)> + '_ {
let start = range.start.to_offset(&self);
let end = range.end.to_offset(&self);
let start = range.start.to_offset(self);
let end = range.end.to_offset(self);
let mut cursor = self.cursor::<usize>();
cursor.seek(&start);
@ -4186,7 +4186,7 @@ impl MultiBufferSnapshot {
}
let start =
Anchor::in_buffer(excerpt.id, excerpt.buffer_id, hunk.buffer_range.start)
.to_point(&self);
.to_point(self);
return Some(MultiBufferRow(start.row));
}
}
@ -4204,7 +4204,7 @@ impl MultiBufferSnapshot {
continue;
};
let start = Anchor::in_buffer(excerpt.id, excerpt.buffer_id, hunk.buffer_range.start)
.to_point(&self);
.to_point(self);
return Some(MultiBufferRow(start.row));
}
}
@ -4455,7 +4455,7 @@ impl MultiBufferSnapshot {
let mut buffer_position = region.buffer_range.start;
buffer_position.add_assign(&overshoot);
let clipped_buffer_position =
clip_buffer_position(&region.buffer, buffer_position, bias);
clip_buffer_position(region.buffer, buffer_position, bias);
let mut position = region.range.start;
position.add_assign(&(clipped_buffer_position - region.buffer_range.start));
position
@ -4485,7 +4485,7 @@ impl MultiBufferSnapshot {
let buffer_start_value = region.buffer_range.start.value.unwrap();
let mut buffer_key = buffer_start_key;
buffer_key.add_assign(&(key - start_key));
let buffer_value = convert_buffer_dimension(&region.buffer, buffer_key);
let buffer_value = convert_buffer_dimension(region.buffer, buffer_key);
let mut result = start_value;
result.add_assign(&(buffer_value - buffer_start_value));
result
@ -4633,7 +4633,7 @@ impl MultiBufferSnapshot {
.as_str()
== **delimiter
{
indent.push_str(&delimiter);
indent.push_str(delimiter);
break;
}
}
@ -4897,8 +4897,8 @@ impl MultiBufferSnapshot {
if let Some(base_text) =
self.diffs.get(buffer_id).map(|diff| diff.base_text())
{
if base_text.can_resolve(&diff_base_anchor) {
let base_text_offset = diff_base_anchor.to_offset(&base_text);
if base_text.can_resolve(diff_base_anchor) {
let base_text_offset = diff_base_anchor.to_offset(base_text);
if base_text_offset >= base_text_byte_range.start
&& base_text_offset <= base_text_byte_range.end
{
@ -6418,7 +6418,7 @@ impl MultiBufferSnapshot {
for (ix, entry) in excerpt_ids.iter().enumerate() {
if ix == 0 {
if entry.id.cmp(&ExcerptId::min(), &self).is_le() {
if entry.id.cmp(&ExcerptId::min(), self).is_le() {
panic!("invalid first excerpt id {:?}", entry.id);
}
} else if entry.id <= excerpt_ids[ix - 1].id {
@ -6648,7 +6648,7 @@ where
hunk_info,
..
} => {
let diff = self.diffs.get(&buffer_id)?;
let diff = self.diffs.get(buffer_id)?;
let buffer = diff.base_text();
let mut rope_cursor = buffer.as_rope().cursor(0);
let buffer_start = rope_cursor.summary::<D>(base_text_byte_range.start);
@ -7767,7 +7767,7 @@ impl<'a> Iterator for MultiBufferChunks<'a> {
}
chunks
} else {
let base_buffer = &self.diffs.get(&buffer_id)?.base_text();
let base_buffer = &self.diffs.get(buffer_id)?.base_text();
base_buffer.chunks(base_text_start..base_text_end, self.language_aware)
};

View file

@ -473,7 +473,7 @@ fn test_editing_text_in_diff_hunks(cx: &mut TestAppContext) {
let base_text = "one\ntwo\nfour\nfive\nsix\nseven\n";
let text = "one\ntwo\nTHREE\nfour\nfive\nseven\n";
let buffer = cx.new(|cx| Buffer::local(text, cx));
let diff = cx.new(|cx| BufferDiff::new_with_base_text(&base_text, &buffer, cx));
let diff = cx.new(|cx| BufferDiff::new_with_base_text(base_text, &buffer, cx));
let multibuffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx));
let (mut snapshot, mut subscription) = multibuffer.update(cx, |multibuffer, cx| {
@ -2265,14 +2265,14 @@ impl ReferenceMultibuffer {
}
if !excerpt.expanded_diff_hunks.iter().any(|expanded_anchor| {
expanded_anchor.to_offset(&buffer).max(buffer_range.start)
expanded_anchor.to_offset(buffer).max(buffer_range.start)
== hunk_range.start.max(buffer_range.start)
}) {
log::trace!("skipping a hunk that's not marked as expanded");
continue;
}
if !hunk.buffer_range.start.is_valid(&buffer) {
if !hunk.buffer_range.start.is_valid(buffer) {
log::trace!("skipping hunk with deleted start: {:?}", hunk.range);
continue;
}
@ -2449,7 +2449,7 @@ impl ReferenceMultibuffer {
return false;
}
while let Some(hunk) = hunks.peek() {
match hunk.buffer_range.start.cmp(&hunk_anchor, &buffer) {
match hunk.buffer_range.start.cmp(hunk_anchor, &buffer) {
cmp::Ordering::Less => {
hunks.next();
}
@ -2519,8 +2519,8 @@ async fn test_random_set_ranges(cx: &mut TestAppContext, mut rng: StdRng) {
let mut seen_ranges = Vec::default();
for (_, buf, range) in snapshot.excerpts() {
let start = range.context.start.to_point(&buf);
let end = range.context.end.to_point(&buf);
let start = range.context.start.to_point(buf);
let end = range.context.end.to_point(buf);
seen_ranges.push(start..end);
if let Some(last_end) = last_end.take() {
@ -2739,9 +2739,8 @@ async fn test_random_multibuffer(cx: &mut TestAppContext, mut rng: StdRng) {
let id = buffer_handle.read(cx).remote_id();
if multibuffer.diff_for(id).is_none() {
let base_text = base_texts.get(&id).unwrap();
let diff = cx.new(|cx| {
BufferDiff::new_with_base_text(base_text, &buffer_handle, cx)
});
let diff = cx
.new(|cx| BufferDiff::new_with_base_text(base_text, buffer_handle, cx));
reference.add_diff(diff.clone(), cx);
multibuffer.add_diff(diff, cx)
}
@ -3604,7 +3603,7 @@ fn assert_position_translation(snapshot: &MultiBufferSnapshot) {
offsets[ix - 1],
);
assert!(
prev_anchor.cmp(&anchor, snapshot).is_lt(),
prev_anchor.cmp(anchor, snapshot).is_lt(),
"anchor({}, {bias:?}).cmp(&anchor({}, {bias:?}).is_lt()",
offsets[ix - 1],
offsets[ix],

View file

@ -126,17 +126,17 @@ impl<T> Default for TypedRow<T> {
impl<T> PartialOrd for TypedOffset<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(&other))
Some(self.cmp(other))
}
}
impl<T> PartialOrd for TypedPoint<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(&other))
Some(self.cmp(other))
}
}
impl<T> PartialOrd for TypedRow<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(&other))
Some(self.cmp(other))
}
}