Some clippy fixes (#36544)
These showed up today, so just applied the simplifications, which were mostly switching matches to if let Release Notes: - N/A
This commit is contained in:
parent
cac80e2ebd
commit
ceec258bf3
3 changed files with 117 additions and 126 deletions
|
@ -93,8 +93,8 @@ impl DivInspector {
|
|||
Ok((json_style_buffer, rust_style_buffer)) => {
|
||||
this.update_in(cx, |this, window, cx| {
|
||||
this.state = State::BuffersLoaded {
|
||||
json_style_buffer: json_style_buffer,
|
||||
rust_style_buffer: rust_style_buffer,
|
||||
json_style_buffer,
|
||||
rust_style_buffer,
|
||||
};
|
||||
|
||||
// Initialize editors immediately instead of waiting for
|
||||
|
@ -200,8 +200,8 @@ impl DivInspector {
|
|||
cx.subscribe_in(&json_style_editor, window, {
|
||||
let id = id.clone();
|
||||
let rust_style_buffer = rust_style_buffer.clone();
|
||||
move |this, editor, event: &EditorEvent, window, cx| match event {
|
||||
EditorEvent::BufferEdited => {
|
||||
move |this, editor, event: &EditorEvent, window, cx| {
|
||||
if event == &EditorEvent::BufferEdited {
|
||||
let style_json = editor.read(cx).text(cx);
|
||||
match serde_json_lenient::from_str_lenient::<StyleRefinement>(&style_json) {
|
||||
Ok(new_style) => {
|
||||
|
@ -243,7 +243,6 @@ impl DivInspector {
|
|||
Err(err) => this.json_style_error = Some(err.to_string().into()),
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
@ -251,11 +250,10 @@ impl DivInspector {
|
|||
cx.subscribe(&rust_style_editor, {
|
||||
let json_style_buffer = json_style_buffer.clone();
|
||||
let rust_style_buffer = rust_style_buffer.clone();
|
||||
move |this, _editor, event: &EditorEvent, cx| match event {
|
||||
EditorEvent::BufferEdited => {
|
||||
move |this, _editor, event: &EditorEvent, cx| {
|
||||
if let EditorEvent::BufferEdited = event {
|
||||
this.update_json_style_from_rust(&json_style_buffer, &rust_style_buffer, cx);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
@ -271,23 +269,19 @@ impl DivInspector {
|
|||
}
|
||||
|
||||
fn reset_style(&mut self, cx: &mut App) {
|
||||
match &self.state {
|
||||
State::Ready {
|
||||
rust_style_buffer,
|
||||
json_style_buffer,
|
||||
..
|
||||
} => {
|
||||
if let Err(err) = self.reset_style_editors(
|
||||
&rust_style_buffer.clone(),
|
||||
&json_style_buffer.clone(),
|
||||
cx,
|
||||
) {
|
||||
self.json_style_error = Some(format!("{err}").into());
|
||||
} else {
|
||||
self.json_style_error = None;
|
||||
}
|
||||
if let State::Ready {
|
||||
rust_style_buffer,
|
||||
json_style_buffer,
|
||||
..
|
||||
} = &self.state
|
||||
{
|
||||
if let Err(err) =
|
||||
self.reset_style_editors(&rust_style_buffer.clone(), &json_style_buffer.clone(), cx)
|
||||
{
|
||||
self.json_style_error = Some(format!("{err}").into());
|
||||
} else {
|
||||
self.json_style_error = None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2125,109 +2125,106 @@ impl SshRemoteConnection {
|
|||
.env("RUSTFLAGS", &rust_flags),
|
||||
)
|
||||
.await?;
|
||||
} else if build_remote_server.contains("cross") {
|
||||
#[cfg(target_os = "windows")]
|
||||
use util::paths::SanitizedPath;
|
||||
|
||||
delegate.set_status(Some("Installing cross.rs for cross-compilation"), cx);
|
||||
log::info!("installing cross");
|
||||
run_cmd(Command::new("cargo").args([
|
||||
"install",
|
||||
"cross",
|
||||
"--git",
|
||||
"https://github.com/cross-rs/cross",
|
||||
]))
|
||||
.await?;
|
||||
|
||||
delegate.set_status(
|
||||
Some(&format!(
|
||||
"Building remote server binary from source for {} with Docker",
|
||||
&triple
|
||||
)),
|
||||
cx,
|
||||
);
|
||||
log::info!("building remote server binary from source for {}", &triple);
|
||||
|
||||
// On Windows, the binding needs to be set to the canonical path
|
||||
#[cfg(target_os = "windows")]
|
||||
let src =
|
||||
SanitizedPath::from(smol::fs::canonicalize("./target").await?).to_glob_string();
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let src = "./target";
|
||||
run_cmd(
|
||||
Command::new("cross")
|
||||
.args([
|
||||
"build",
|
||||
"--package",
|
||||
"remote_server",
|
||||
"--features",
|
||||
"debug-embed",
|
||||
"--target-dir",
|
||||
"target/remote_server",
|
||||
"--target",
|
||||
&triple,
|
||||
])
|
||||
.env(
|
||||
"CROSS_CONTAINER_OPTS",
|
||||
format!("--mount type=bind,src={src},dst=/app/target"),
|
||||
)
|
||||
.env("RUSTFLAGS", &rust_flags),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
if build_remote_server.contains("cross") {
|
||||
#[cfg(target_os = "windows")]
|
||||
use util::paths::SanitizedPath;
|
||||
let which = cx
|
||||
.background_spawn(async move { which::which("zig") })
|
||||
.await;
|
||||
|
||||
delegate.set_status(Some("Installing cross.rs for cross-compilation"), cx);
|
||||
log::info!("installing cross");
|
||||
run_cmd(Command::new("cargo").args([
|
||||
"install",
|
||||
"cross",
|
||||
"--git",
|
||||
"https://github.com/cross-rs/cross",
|
||||
]))
|
||||
.await?;
|
||||
|
||||
delegate.set_status(
|
||||
Some(&format!(
|
||||
"Building remote server binary from source for {} with Docker",
|
||||
&triple
|
||||
)),
|
||||
cx,
|
||||
);
|
||||
log::info!("building remote server binary from source for {}", &triple);
|
||||
|
||||
// On Windows, the binding needs to be set to the canonical path
|
||||
#[cfg(target_os = "windows")]
|
||||
let src =
|
||||
SanitizedPath::from(smol::fs::canonicalize("./target").await?).to_glob_string();
|
||||
if which.is_err() {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let src = "./target";
|
||||
run_cmd(
|
||||
Command::new("cross")
|
||||
.args([
|
||||
"build",
|
||||
"--package",
|
||||
"remote_server",
|
||||
"--features",
|
||||
"debug-embed",
|
||||
"--target-dir",
|
||||
"target/remote_server",
|
||||
"--target",
|
||||
&triple,
|
||||
])
|
||||
.env(
|
||||
"CROSS_CONTAINER_OPTS",
|
||||
format!("--mount type=bind,src={src},dst=/app/target"),
|
||||
)
|
||||
.env("RUSTFLAGS", &rust_flags),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
let which = cx
|
||||
.background_spawn(async move { which::which("zig") })
|
||||
.await;
|
||||
|
||||
if which.is_err() {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
anyhow::bail!(
|
||||
"zig not found on $PATH, install zig (see https://ziglang.org/learn/getting-started or use zigup) or pass ZED_BUILD_REMOTE_SERVER=cross to use cross"
|
||||
)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
anyhow::bail!(
|
||||
"zig not found on $PATH, install zig (use `winget install -e --id zig.zig` or see https://ziglang.org/learn/getting-started or use zigup) or pass ZED_BUILD_REMOTE_SERVER=cross to use cross"
|
||||
)
|
||||
}
|
||||
{
|
||||
anyhow::bail!(
|
||||
"zig not found on $PATH, install zig (see https://ziglang.org/learn/getting-started or use zigup) or pass ZED_BUILD_REMOTE_SERVER=cross to use cross"
|
||||
)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
anyhow::bail!(
|
||||
"zig not found on $PATH, install zig (use `winget install -e --id zig.zig` or see https://ziglang.org/learn/getting-started or use zigup) or pass ZED_BUILD_REMOTE_SERVER=cross to use cross"
|
||||
)
|
||||
}
|
||||
|
||||
delegate.set_status(Some("Adding rustup target for cross-compilation"), cx);
|
||||
log::info!("adding rustup target");
|
||||
run_cmd(Command::new("rustup").args(["target", "add"]).arg(&triple)).await?;
|
||||
|
||||
delegate.set_status(Some("Installing cargo-zigbuild for cross-compilation"), cx);
|
||||
log::info!("installing cargo-zigbuild");
|
||||
run_cmd(Command::new("cargo").args(["install", "--locked", "cargo-zigbuild"]))
|
||||
.await?;
|
||||
|
||||
delegate.set_status(
|
||||
Some(&format!(
|
||||
"Building remote binary from source for {triple} with Zig"
|
||||
)),
|
||||
cx,
|
||||
);
|
||||
log::info!("building remote binary from source for {triple} with Zig");
|
||||
run_cmd(
|
||||
Command::new("cargo")
|
||||
.args([
|
||||
"zigbuild",
|
||||
"--package",
|
||||
"remote_server",
|
||||
"--features",
|
||||
"debug-embed",
|
||||
"--target-dir",
|
||||
"target/remote_server",
|
||||
"--target",
|
||||
&triple,
|
||||
])
|
||||
.env("RUSTFLAGS", &rust_flags),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
delegate.set_status(Some("Adding rustup target for cross-compilation"), cx);
|
||||
log::info!("adding rustup target");
|
||||
run_cmd(Command::new("rustup").args(["target", "add"]).arg(&triple)).await?;
|
||||
|
||||
delegate.set_status(Some("Installing cargo-zigbuild for cross-compilation"), cx);
|
||||
log::info!("installing cargo-zigbuild");
|
||||
run_cmd(Command::new("cargo").args(["install", "--locked", "cargo-zigbuild"])).await?;
|
||||
|
||||
delegate.set_status(
|
||||
Some(&format!(
|
||||
"Building remote binary from source for {triple} with Zig"
|
||||
)),
|
||||
cx,
|
||||
);
|
||||
log::info!("building remote binary from source for {triple} with Zig");
|
||||
run_cmd(
|
||||
Command::new("cargo")
|
||||
.args([
|
||||
"zigbuild",
|
||||
"--package",
|
||||
"remote_server",
|
||||
"--features",
|
||||
"debug-embed",
|
||||
"--target-dir",
|
||||
"target/remote_server",
|
||||
"--target",
|
||||
&triple,
|
||||
])
|
||||
.env("RUSTFLAGS", &rust_flags),
|
||||
)
|
||||
.await?;
|
||||
};
|
||||
let bin_path = Path::new("target")
|
||||
.join("remote_server")
|
||||
|
|
|
@ -299,10 +299,10 @@ impl NeovimConnection {
|
|||
if let Some(NeovimData::Get { .. }) = self.data.front() {
|
||||
self.data.pop_front();
|
||||
};
|
||||
if let Some(NeovimData::ReadRegister { name, value }) = self.data.pop_front() {
|
||||
if name == register {
|
||||
return value;
|
||||
}
|
||||
if let Some(NeovimData::ReadRegister { name, value }) = self.data.pop_front()
|
||||
&& name == register
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
panic!("operation does not match recorded script. re-record with --features=neovim")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue