chiark / gitweb /
clippy: Miscellaneous minor changes, and allow lints
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 19:25:30 +0000 (20:25 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 19:25:30 +0000 (20:25 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cli/clisupport.rs
clippy-options
jstest/jst-lower.rs
jstest/jstest.rs
wdriver/wdriver.rs

index e405f63218b26913a4b5cd8b4bd3e885fb7461e2..fd54f27a41319d7e3ac8309ae8f0a2818ab72081 100644 (file)
@@ -63,7 +63,7 @@ pub fn default_ssh_proxy_command() -> String {
 
 impl MainOpts {
   pub fn game(&self) -> &str {
-    self.game.as_ref().map(|s| s.as_str()).unwrap_or_else(||{
+    self.game.as_deref().unwrap_or_else(||{
       eprintln!(
         "game (table) name not specified; pass --game option");
       exit(EXIT_USAGE);
@@ -71,7 +71,7 @@ impl MainOpts {
   }
 
   pub fn instance(&self) -> InstanceName {
-    match self.game().strip_prefix(":") {
+    match self.game().strip_prefix(':') {
       Some(rest) => {
         InstanceName {
           account: self.account.clone(),
@@ -422,7 +422,7 @@ pub fn setup_table(_ma: &MainOpts, instance_name: &InstanceName, spec: &TableSpe
                -> Vec<MGI> {
   let TableSpec { players, player_perms, acl, links } = spec;
   let mut player_perms = player_perms.clone()
-    .unwrap_or(PLAYER_DEFAULT_PERMS.iter().cloned().collect());
+    .unwrap_or_else(|| PLAYER_DEFAULT_PERMS.iter().cloned().collect());
   player_perms.extend(PLAYER_ALWAYS_PERMS.iter());
 
   let acl: RawAcl<_> =
index cdc6fc0009fa0e3dd6ff8849e3c0deca6d63bf03..b4cfc50f360636e79fe9e45ae397272cd0b28e65 100644 (file)
@@ -36,3 +36,4 @@
 -A clippy::manual_map
 -A clippy::vec_init_then_push
 -A clippy::collapsible_if
+-A clippy::iter_nth_zero
index 610c156fc5db1f3cc73e2ddb7886f8c50b328dad..b44d611efbb97b00b9d5c17fc21bd620951fc877 100644 (file)
@@ -4,6 +4,9 @@
 
 // OTTER_JST_LOWER_ONLY=exhaustive-05
 
+#![allow(clippy::or_fun_call)]
+#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)]
+
 use otter_nodejs_tests::*;
 
 pub type Vpid = VisiblePieceId;
@@ -167,7 +170,7 @@ impl Test {
         id, new_z, old_z, updated,
         heavy: start.heavy(),
         target: self.targets.contains(&id),
-        zupd: start.zupd.into(),
+        zupd: start.zupd,
       }
     }).collect_vec();
 
@@ -188,8 +191,8 @@ impl Test {
                 p.zupd.show(),
                 zl.show());
       };
-      pr(o, &o.old_z); print!("    ");
-      pr(n, &n.new_z); println!("");
+      pr(o, o.old_z); print!("    ");
+      pr(n, n.new_z); println!("");
     }
 
     // light targets are in same stacking order as before
@@ -518,7 +521,7 @@ fn main() {
   tests.finish()?;
 }
 
-static TEMPLATE: &'static str = r#"
+static TEMPLATE: &str = r#"
 
 console.log('-------------------- {{ name }} --------------------')
 jstest_did = fs.openSync('{{ name }}.did', 'w');
index fdc46010899b9173143aeb0f61a411908bfec524..b352cc15c096ba2f026f2c32d017e85950f1bc1a 100644 (file)
@@ -2,6 +2,9 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
+#![allow(clippy::or_fun_call)]
+#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)]
+
 pub use otter::imports::*;
 pub use otter::prelude::*;
 
index ae5781d30def7693ffea5b32988c0a64eb1a3390..1f8a3ffcb27ce08c8bd61ebd224641f75dbba9f7 100644 (file)
@@ -2,6 +2,9 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
+#![allow(clippy::or_fun_call)]
+#![allow(clippy::unnecessary_operation)] // trips on #[throws(Explode)]
+
 pub use otter_api_tests::*;
 pub use otter_api_tests as apitest;
 
@@ -149,16 +152,16 @@ fn prepare_thirtyfour(ds: &DirSubst)
   ].iter().cloned().collect();
   caps.add("prefs", prefs)?;
   caps.add("stdio", "inherit")?;
-  let mut driver = t4::WebDriver::new("http://localhost:4444", &caps)
+  let driver = t4::WebDriver::new("http://localhost:4444", &caps)
     .context("create 34 WebDriver")?;
 
   const FRONT: &str = "front";
-  let mut js_logfile = JsLogfileImp::open(&ds, FRONT)?;
+  let mut js_logfile = JsLogfileImp::open(ds, FRONT)?;
 
   driver.set_window_name(FRONT).context("set initial window name")?;
-  screenshot(&mut driver, &mut count, "startup", log::Level::Trace)?;
+  screenshot(&driver, &mut count, "startup", log::Level::Trace)?;
   driver.get(URL).context("navigate to front page")?;
-  screenshot(&mut driver, &mut count, "front", log::Level::Trace)?;
+  screenshot(&driver, &mut count, "front", log::Level::Trace)?;
 
   js_logfile.fetch(&driver)?;
   let js_logs = vec![Rc::new(RefCell::new(js_logfile))];
@@ -346,8 +349,7 @@ impl<'g> WindowGuard<'g> {
     let elemid = format!("use{}", &pieceid);
     let elem = self.su.driver.find_element(By::Id(&elemid))?;
     PieceElement {
-      elem,
-      pieceid: pieceid.clone(),
+      elem, pieceid,
       w: self,
     }
   }
@@ -458,7 +460,7 @@ impl<'g> WindowGuard<'g> {
       dbg!(log)
     }
 
-    inner(&self, &mut move |s| ignore_before.matches(s))?
+    inner(self, &mut move |s| ignore_before.matches(s))?
   }
 
   #[throws(AE)]