chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz
2024-09-06 11:58:39 +02:00
committed by GitHub
parent 93249fc82b
commit e6c1c51b37
361 changed files with 3529 additions and 3586 deletions
+8 -8
View File
@@ -60,9 +60,9 @@ pub struct BlockSnapshot {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CustomBlockId(usize);
impl Into<ElementId> for CustomBlockId {
fn into(self) -> ElementId {
ElementId::Integer(self.0)
impl From<CustomBlockId> for ElementId {
fn from(val: CustomBlockId) -> Self {
ElementId::Integer(val.0)
}
}
@@ -657,7 +657,7 @@ impl BlockMap {
.flatten()
}
pub(crate) fn sort_blocks<B: BlockLike>(blocks: &mut Vec<(u32, B)>) {
pub(crate) fn sort_blocks<B: BlockLike>(blocks: &mut [(u32, B)]) {
// Place excerpt headers and footers above custom blocks on the same row
blocks.sort_unstable_by(|(row_a, block_a), (row_b, block_b)| {
row_a.cmp(row_b).then_with(|| {
@@ -1478,7 +1478,7 @@ mod tests {
#[gpui::test]
fn test_basic_blocks(cx: &mut gpui::TestAppContext) {
cx.update(|cx| init_test(cx));
cx.update(init_test);
let text = "aaa\nbbb\nccc\nddd";
@@ -1734,7 +1734,7 @@ mod tests {
#[gpui::test]
fn test_replace_with_heights(cx: &mut gpui::TestAppContext) {
let _update = cx.update(|cx| init_test(cx));
cx.update(init_test);
let text = "aaa\nbbb\nccc\nddd";
@@ -1838,7 +1838,7 @@ mod tests {
#[cfg(target_os = "macos")]
#[gpui::test]
fn test_blocks_on_wrapped_lines(cx: &mut gpui::TestAppContext) {
cx.update(|cx| init_test(cx));
cx.update(init_test);
let _font_id = cx.text_system().font_id(&font("Helvetica")).unwrap();
@@ -1885,7 +1885,7 @@ mod tests {
#[gpui::test(iterations = 100)]
fn test_random_blocks(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
cx.update(|cx| init_test(cx));
cx.update(init_test);
let operations = env::var("OPERATIONS")
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
+2 -2
View File
@@ -46,7 +46,7 @@ impl CreaseSnapshot {
Ordering::Greater => break,
}
}
return None;
None
}
pub fn crease_items_with_offsets(
@@ -183,7 +183,7 @@ impl CreaseMap {
}
}
removals.sort_unstable_by(|(a_id, a_range), (b_id, b_range)| {
AnchorRangeExt::cmp(a_range, b_range, snapshot).then(b_id.cmp(&a_id))
AnchorRangeExt::cmp(a_range, b_range, snapshot).then(b_id.cmp(a_id))
});
self.snapshot.creases = {
+11 -13
View File
@@ -122,7 +122,7 @@ impl<'a> FoldMapWriter<'a> {
let snapshot = self.0.snapshot.inlay_snapshot.clone();
for (range, fold_text) in ranges.into_iter() {
let buffer = &snapshot.buffer;
let range = range.start.to_offset(&buffer)..range.end.to_offset(&buffer);
let range = range.start.to_offset(buffer)..range.end.to_offset(buffer);
// Ignore any empty ranges.
if range.start == range.end {
@@ -420,7 +420,7 @@ impl FoldMap {
}
if fold_range.end > fold_range.start {
const ELLIPSIS: &'static str = "⋯";
const ELLIPSIS: &str = "⋯";
let fold_id = fold.id;
new_transforms.push(
@@ -850,7 +850,8 @@ fn consolidate_inlay_edits(mut edits: Vec<InlayEdit>) -> Vec<InlayEdit> {
let _old_alloc_ptr = edits.as_ptr();
let mut inlay_edits = edits.into_iter();
let inlay_edits = if let Some(mut first_edit) = inlay_edits.next() {
if let Some(mut first_edit) = inlay_edits.next() {
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
#[allow(clippy::filter_map_identity)]
let mut v: Vec<_> = inlay_edits
@@ -872,9 +873,7 @@ fn consolidate_inlay_edits(mut edits: Vec<InlayEdit>) -> Vec<InlayEdit> {
v
} else {
vec![]
};
inlay_edits
}
}
fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
@@ -886,7 +885,8 @@ fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
});
let _old_alloc_ptr = edits.as_ptr();
let mut fold_edits = edits.into_iter();
let fold_edits = if let Some(mut first_edit) = fold_edits.next() {
if let Some(mut first_edit) = fold_edits.next() {
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
#[allow(clippy::filter_map_identity)]
let mut v: Vec<_> = fold_edits
@@ -907,9 +907,7 @@ fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
v
} else {
vec![]
};
fold_edits
}
}
#[derive(Clone, Debug, Default)]
@@ -956,9 +954,9 @@ impl sum_tree::Summary for TransformSummary {
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
pub struct FoldId(usize);
impl Into<ElementId> for FoldId {
fn into(self) -> ElementId {
ElementId::Integer(self.0)
impl From<FoldId> for ElementId {
fn from(val: FoldId) -> Self {
ElementId::Integer(val.0)
}
}
+8 -9
View File
@@ -324,7 +324,7 @@ impl<'a> Iterator for InlayChunks<'a> {
} else {
next_inlay_highlight_endpoint = range.end - offset_in_inlay.0;
highlight_style
.get_or_insert_with(|| Default::default())
.get_or_insert_with(Default::default)
.highlight(*style);
}
} else {
@@ -451,15 +451,14 @@ impl InlayMap {
) -> (InlaySnapshot, Vec<InlayEdit>) {
let snapshot = &mut self.snapshot;
if buffer_edits.is_empty() {
if snapshot.buffer.trailing_excerpt_update_count()
if buffer_edits.is_empty()
&& snapshot.buffer.trailing_excerpt_update_count()
!= buffer_snapshot.trailing_excerpt_update_count()
{
buffer_edits.push(Edit {
old: snapshot.buffer.len()..snapshot.buffer.len(),
new: buffer_snapshot.len()..buffer_snapshot.len(),
});
}
{
buffer_edits.push(Edit {
old: snapshot.buffer.len()..snapshot.buffer.len(),
new: buffer_snapshot.len()..buffer_snapshot.len(),
});
}
if buffer_edits.is_empty() {
+1 -1
View File
@@ -654,7 +654,7 @@ mod tests {
fn test_marking_tabs(cx: &mut gpui::AppContext) {
let input = "\t \thello";
let buffer = MultiBuffer::build_simple(&input, cx);
let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
+5 -6
View File
@@ -111,7 +111,7 @@ impl WrapMap {
} else {
self.edits_since_sync = self
.edits_since_sync
.compose(&self.snapshot.interpolate(tab_snapshot, &edits));
.compose(self.snapshot.interpolate(tab_snapshot, &edits));
self.snapshot.interpolated = false;
}
@@ -213,7 +213,7 @@ impl WrapMap {
}
let new_rows = self.snapshot.transforms.summary().output.lines.row + 1;
self.snapshot.interpolated = false;
self.edits_since_sync = self.edits_since_sync.compose(&Patch::new(vec![WrapEdit {
self.edits_since_sync = self.edits_since_sync.compose(Patch::new(vec![WrapEdit {
old: 0..old_rows,
new: 0..new_rows,
}]));
@@ -1009,7 +1009,8 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for WrapPoint {
fn consolidate_wrap_edits(edits: Vec<WrapEdit>) -> Vec<WrapEdit> {
let _old_alloc_ptr = edits.as_ptr();
let mut wrap_edits = edits.into_iter();
let wrap_edits = if let Some(mut first_edit) = wrap_edits.next() {
if let Some(mut first_edit) = wrap_edits.next() {
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
#[allow(clippy::filter_map_identity)]
let mut v: Vec<_> = wrap_edits
@@ -1030,9 +1031,7 @@ fn consolidate_wrap_edits(edits: Vec<WrapEdit>) -> Vec<WrapEdit> {
v
} else {
vec![]
};
wrap_edits
}
}
#[cfg(test)]