Skip to content

Commit 487aa05

Browse files
authored
clippy fixes for rust 1.95 (#5522)
* clippy fixes for rust 1.95 * fmt
1 parent 276150f commit 487aa05

9 files changed

Lines changed: 37 additions & 53 deletions

File tree

examples/01-app-demos/calculator.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ fn app() -> Element {
4949
let mut input_operator = move |key: &str| val.push_str(key);
5050

5151
let handle_key_down_event = move |evt: KeyboardEvent| match evt.key() {
52-
Key::Backspace => {
53-
if !val().is_empty() {
54-
val.pop();
55-
}
52+
Key::Backspace if !val().is_empty() => {
53+
val.pop();
5654
}
5755
Key::Character(character) => match character.as_str() {
5856
"+" | "-" | "/" | "*" => input_operator(&character),

packages/cli/src/build/builder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,8 @@ impl AppBuilder {
505505
krate,
506506
fresh,
507507
..
508-
} => {
509-
if !fresh {
510-
tracing::info!("Compiled [{current:>3}/{total}]: {krate}");
511-
}
508+
} if !fresh => {
509+
tracing::info!("Compiled [{current:>3}/{total}]: {krate}");
512510
}
513511
BuildStage::RunningBindgen => tracing::info!("Running wasm-bindgen..."),
514512
BuildStage::CopyingAssets {

packages/cli/src/build/request.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,14 +1136,12 @@ impl BuildRequest {
11361136

11371137
// todo: this can occasionally swallow errors, so we should figure out what exactly is going wrong
11381138
// since that is a really bad user experience.
1139-
Message::BuildFinished(finished) => {
1140-
if !finished.success {
1141-
bail!(
1142-
"cargo build finished with errors for target: {} [{}]",
1143-
self.main_target,
1144-
self.triple
1145-
);
1146-
}
1139+
Message::BuildFinished(finished) if !finished.success => {
1140+
bail!(
1141+
"cargo build finished with errors for target: {} [{}]",
1142+
self.main_target,
1143+
self.triple
1144+
);
11471145
}
11481146
_ => {}
11491147
}

packages/cli/src/build/web.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,11 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
473473
);
474474
}
475475
}
476-
AssetVariant::Image(image_options) => {
477-
if image_options.preloaded() {
478-
_ = write!(
479-
head_resources,
480-
r#"<link rel="preload" as="image" href="/{{base_path}}/assets/{asset_path}" crossorigin>"#
481-
);
482-
}
476+
AssetVariant::Image(image_options) if image_options.preloaded() => {
477+
_ = write!(
478+
head_resources,
479+
r#"<link rel="preload" as="image" href="/{{base_path}}/assets/{asset_path}" crossorigin>"#
480+
);
483481
}
484482
AssetVariant::Js(js_options) => {
485483
if js_options.preloaded() {

packages/cli/src/bundler/windows.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,11 @@ fn wix_version(version: &str) -> Result<String> {
945945
.parse()
946946
.with_context(|| format!("Invalid version component: '{part}'"))?;
947947
match i {
948-
0 | 1 => {
949-
if num > 255 {
950-
bail!("Version component {part} exceeds maximum value of 255");
951-
}
948+
0 | 1 if num > 255 => {
949+
bail!("Version component {part} exceeds maximum value of 255");
952950
}
953-
2 | 3 => {
954-
if num > 65535 {
955-
bail!("Version component {part} exceeds maximum value of 65535");
956-
}
951+
2 | 3 if num > 65535 => {
952+
bail!("Version component {part} exceeds maximum value of 65535");
957953
}
958954
_ => {}
959955
}

packages/cli/src/cli/run.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,10 @@ impl RunArgs {
8383
total,
8484
krate,
8585
fresh,
86-
} => {
87-
if !fresh {
88-
tracing::debug!(
89-
"[{bundle_format}] ({current}/{total}) Compiling {krate} ",
90-
)
91-
}
86+
} if !fresh => {
87+
tracing::debug!(
88+
"[{bundle_format}] ({current}/{total}) Compiling {krate} ",
89+
)
9290
}
9391
BuildStage::RunningBindgen => {
9492
tracing::info!("[{bundle_format}] Running WASM bindgen")

packages/cli/src/serve/runner.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,18 +872,17 @@ impl AppServer {
872872
pid: Option<u32>,
873873
) {
874874
match build_id {
875-
BuildId::PRIMARY => {
875+
BuildId::PRIMARY
876876
// multiple tabs on web can cause this to be called incorrectly, and it doesn't
877877
// make any sense anyways
878-
if self.client.build.bundle != BundleFormat::Web {
878+
if self.client.build.bundle != BundleFormat::Web => {
879879
if let Some(aslr_reference) = aslr_reference {
880880
self.client.aslr_reference = Some(aslr_reference);
881881
}
882882
if let Some(pid) = pid {
883883
self.client.pid = Some(pid);
884884
}
885885
}
886-
}
887886
BuildId::SECONDARY => {
888887
if let Some(server) = self.server.as_mut() {
889888
server.aslr_reference = aslr_reference;
@@ -1292,7 +1291,7 @@ impl AppServer {
12921291
.collect();
12931292

12941293
// Longer chain = deeper in dep tree = should compile first
1295-
crates_with_depth.sort_by(|a, b| b.1.cmp(&a.1));
1294+
crates_with_depth.sort_by_key(|b| std::cmp::Reverse(b.1));
12961295
crates_with_depth.into_iter().map(|(c, _)| c).collect()
12971296
}
12981297

packages/cli/src/serve/server.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,16 @@ impl WebServer {
230230
total,
231231
krate,
232232
..
233-
} => {
234-
if !matches!(
235-
self.build_status.get(),
236-
Status::Ready | Status::BuildError { .. }
237-
) {
238-
self.build_status.set(Status::Building {
239-
progress: (*current as f64 / *total as f64).clamp(0.0, 1.0),
240-
build_message: format!("{krate} compiling"),
241-
});
242-
self.send_build_status().await;
243-
}
233+
} if !matches!(
234+
self.build_status.get(),
235+
Status::Ready | Status::BuildError { .. }
236+
) =>
237+
{
238+
self.build_status.set(Status::Building {
239+
progress: (*current as f64 / *total as f64).clamp(0.0, 1.0),
240+
build_message: format!("{krate} compiling"),
241+
});
242+
self.send_build_status().await;
244243
}
245244
BuildStage::OptimizingWasm => {}
246245
BuildStage::Aborted => {}

packages/rsx-rosetta/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn rsx_node_from_html(node: &Node) -> Option<BodyNode> {
9696
// the html-parser crate we use uses a HashMap for attributes. This leads to a
9797
// non-deterministic order of attributes.
9898
// Sort them here
99-
attributes.sort_by(|a, b| a.name.to_string().cmp(&b.name.to_string()));
99+
attributes.sort_by_key(|a| a.name.to_string());
100100

101101
let children = el.children.iter().filter_map(rsx_node_from_html).collect();
102102

0 commit comments

Comments
 (0)