mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-18 18:08:07 +03:00
Enable clippy::never_loop
(#9006)
Three changes: two of which are changing `while let` construct to `if let` as they unconditionally broke and one of which was removing a loop in the `start_default_prettier` as it unconditionally broke in the control flow for match installation task: the diff for this is larger than needed as removing the loop changed a lot of indentation for `rustfmt`.
This commit is contained in:
parent
df27e783ae
commit
61225ecef7
@ -412,7 +412,6 @@ derive_ord_xor_partial_ord = "allow"
|
|||||||
eq_op = "allow"
|
eq_op = "allow"
|
||||||
let_underscore_future = "allow"
|
let_underscore_future = "allow"
|
||||||
map_entry = "allow"
|
map_entry = "allow"
|
||||||
never_loop = "allow"
|
|
||||||
non_canonical_clone_impl = "allow"
|
non_canonical_clone_impl = "allow"
|
||||||
non_canonical_partial_ord_impl = "allow"
|
non_canonical_partial_ord_impl = "allow"
|
||||||
reversed_empty_ranges = "allow"
|
reversed_empty_ranges = "allow"
|
||||||
|
@ -2094,7 +2094,7 @@ impl Conversation {
|
|||||||
let buffer = self.buffer.read(cx);
|
let buffer = self.buffer.read(cx);
|
||||||
let mut message_anchors = self.message_anchors.iter().enumerate().peekable();
|
let mut message_anchors = self.message_anchors.iter().enumerate().peekable();
|
||||||
iter::from_fn(move || {
|
iter::from_fn(move || {
|
||||||
while let Some((start_ix, message_anchor)) = message_anchors.next() {
|
if let Some((start_ix, message_anchor)) = message_anchors.next() {
|
||||||
let metadata = self.messages_metadata.get(&message_anchor.id)?;
|
let metadata = self.messages_metadata.get(&message_anchor.id)?;
|
||||||
let message_start = message_anchor.start.to_offset(buffer);
|
let message_start = message_anchor.start.to_offset(buffer);
|
||||||
let mut message_end = None;
|
let mut message_end = None;
|
||||||
|
@ -1349,7 +1349,7 @@ impl MultiBuffer {
|
|||||||
cursor.next(&());
|
cursor.next(&());
|
||||||
|
|
||||||
// Skip over any subsequent excerpts that are also removed.
|
// Skip over any subsequent excerpts that are also removed.
|
||||||
while let Some(&next_excerpt_id) = excerpt_ids.peek() {
|
if let Some(&next_excerpt_id) = excerpt_ids.peek() {
|
||||||
let next_locator = snapshot.excerpt_locator_for_id(next_excerpt_id);
|
let next_locator = snapshot.excerpt_locator_for_id(next_excerpt_id);
|
||||||
if let Some(next_excerpt) = cursor.item() {
|
if let Some(next_excerpt) = cursor.item() {
|
||||||
if next_excerpt.locator == *next_locator {
|
if next_excerpt.locator == *next_locator {
|
||||||
@ -1358,7 +1358,6 @@ impl MultiBuffer {
|
|||||||
continue 'remove_excerpts;
|
continue 'remove_excerpts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -230,68 +230,66 @@ fn start_default_prettier(
|
|||||||
cx: &mut ModelContext<'_, Project>,
|
cx: &mut ModelContext<'_, Project>,
|
||||||
) -> Task<anyhow::Result<PrettierTask>> {
|
) -> Task<anyhow::Result<PrettierTask>> {
|
||||||
cx.spawn(|project, mut cx| async move {
|
cx.spawn(|project, mut cx| async move {
|
||||||
loop {
|
let installation_task = project.update(&mut cx, |project, _| {
|
||||||
let installation_task = project.update(&mut cx, |project, _| {
|
match &project.default_prettier.prettier {
|
||||||
match &project.default_prettier.prettier {
|
PrettierInstallation::NotInstalled {
|
||||||
PrettierInstallation::NotInstalled {
|
installation_task, ..
|
||||||
installation_task, ..
|
} => ControlFlow::Continue(installation_task.clone()),
|
||||||
} => ControlFlow::Continue(installation_task.clone()),
|
PrettierInstallation::Installed(default_prettier) => {
|
||||||
PrettierInstallation::Installed(default_prettier) => {
|
ControlFlow::Break(default_prettier.clone())
|
||||||
ControlFlow::Break(default_prettier.clone())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})?;
|
}
|
||||||
match installation_task {
|
})?;
|
||||||
ControlFlow::Continue(None) => {
|
match installation_task {
|
||||||
anyhow::bail!("Default prettier is not installed and cannot be started")
|
ControlFlow::Continue(None) => {
|
||||||
|
anyhow::bail!("Default prettier is not installed and cannot be started")
|
||||||
|
}
|
||||||
|
ControlFlow::Continue(Some(installation_task)) => {
|
||||||
|
log::info!("Waiting for default prettier to install");
|
||||||
|
if let Err(e) = installation_task.await {
|
||||||
|
project.update(&mut cx, |project, _| {
|
||||||
|
if let PrettierInstallation::NotInstalled {
|
||||||
|
installation_task,
|
||||||
|
attempts,
|
||||||
|
..
|
||||||
|
} = &mut project.default_prettier.prettier
|
||||||
|
{
|
||||||
|
*installation_task = None;
|
||||||
|
*attempts += 1;
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
anyhow::bail!(
|
||||||
|
"Cannot start default prettier due to its installation failure: {e:#}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ControlFlow::Continue(Some(installation_task)) => {
|
let new_default_prettier = project.update(&mut cx, |project, cx| {
|
||||||
log::info!("Waiting for default prettier to install");
|
let new_default_prettier =
|
||||||
if let Err(e) = installation_task.await {
|
start_prettier(node, DEFAULT_PRETTIER_DIR.clone(), worktree_id, cx);
|
||||||
project.update(&mut cx, |project, _| {
|
project.default_prettier.prettier =
|
||||||
if let PrettierInstallation::NotInstalled {
|
PrettierInstallation::Installed(PrettierInstance {
|
||||||
installation_task,
|
attempt: 0,
|
||||||
attempts,
|
prettier: Some(new_default_prettier.clone()),
|
||||||
..
|
});
|
||||||
} = &mut project.default_prettier.prettier
|
new_default_prettier
|
||||||
{
|
})?;
|
||||||
*installation_task = None;
|
return Ok(new_default_prettier);
|
||||||
*attempts += 1;
|
}
|
||||||
}
|
ControlFlow::Break(instance) => match instance.prettier {
|
||||||
})?;
|
Some(instance) => return Ok(instance),
|
||||||
anyhow::bail!(
|
None => {
|
||||||
"Cannot start default prettier due to its installation failure: {e:#}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let new_default_prettier = project.update(&mut cx, |project, cx| {
|
let new_default_prettier = project.update(&mut cx, |project, cx| {
|
||||||
let new_default_prettier =
|
let new_default_prettier =
|
||||||
start_prettier(node, DEFAULT_PRETTIER_DIR.clone(), worktree_id, cx);
|
start_prettier(node, DEFAULT_PRETTIER_DIR.clone(), worktree_id, cx);
|
||||||
project.default_prettier.prettier =
|
project.default_prettier.prettier =
|
||||||
PrettierInstallation::Installed(PrettierInstance {
|
PrettierInstallation::Installed(PrettierInstance {
|
||||||
attempt: 0,
|
attempt: instance.attempt + 1,
|
||||||
prettier: Some(new_default_prettier.clone()),
|
prettier: Some(new_default_prettier.clone()),
|
||||||
});
|
});
|
||||||
new_default_prettier
|
new_default_prettier
|
||||||
})?;
|
})?;
|
||||||
return Ok(new_default_prettier);
|
return Ok(new_default_prettier);
|
||||||
}
|
}
|
||||||
ControlFlow::Break(instance) => match instance.prettier {
|
},
|
||||||
Some(instance) => return Ok(instance),
|
|
||||||
None => {
|
|
||||||
let new_default_prettier = project.update(&mut cx, |project, cx| {
|
|
||||||
let new_default_prettier =
|
|
||||||
start_prettier(node, DEFAULT_PRETTIER_DIR.clone(), worktree_id, cx);
|
|
||||||
project.default_prettier.prettier =
|
|
||||||
PrettierInstallation::Installed(PrettierInstance {
|
|
||||||
attempt: instance.attempt + 1,
|
|
||||||
prettier: Some(new_default_prettier.clone()),
|
|
||||||
});
|
|
||||||
new_default_prettier
|
|
||||||
})?;
|
|
||||||
return Ok(new_default_prettier);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user