chiark / gitweb /
clippy: Miscellaneous minor changes, and allow lints
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 19:17:01 +0000 (20:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 19:17:01 +0000 (20:17 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/apitest.rs
clippy-options
daemon/main.rs
daemon/session.rs
src/bin/otterlib.rs

index eb557519f75a7eeb48197df34cf1030203b91178..5eec89ed37125b1d80f0c7e0c118bc152acdad09 100644 (file)
@@ -484,14 +484,14 @@ pub fn reinvoke_via_bwrap(_opts: &Opts, current_exe: &str,
     .args("--unshare-net \
            --dev-bind / / \
            --tmpfs /tmp \
-           --die-with-parent".split(" "))
+           --die-with-parent".split(' '))
     .arg(current_exe);
 
   let (early, late) = {
     let mut still_early = true;
     env::args_os().skip(1)
       .partition::<Vec<_>,_>(|s| {
-        still_early &= early(&s);
+        still_early &= early(s);
         still_early
       })
   };
@@ -590,7 +590,7 @@ pub fn prepare_tmpdir<'x>(opts: &'x Opts, mut current_exe: &'x str) -> DirSubst
 
   let manifest_var = "CARGO_MANIFEST_DIR";
   let src: String = (|| Ok::<_,AE>(match env::var(manifest_var) {
-    Ok(dir) => dir.into(),
+    Ok(dir) => dir,
     Err(env::VarError::NotPresent) => start_dir.clone(),
     e@ Err(_) => throw!(e.context(manifest_var).err().unwrap()),
   }))()
@@ -786,7 +786,7 @@ impl DirSubst {
     let exe = ds.subst("@target@/debug/otter")?;
     let specs = self.subst("@src@/specs")?;
     let mut args: Vec<String> = vec![];
-    args.push("--config"  .to_owned()); args.push(prctx.resolve(&CONFIG));
+    args.push("--config"  .to_owned()); args.push(prctx.resolve(CONFIG));
     args.push("--spec-dir".to_owned()); args.push(prctx.resolve(&specs) );
     args.extend(xargs.to_args(ds));
     let dbg = format!("running {} {:?}", &exe, &args);
@@ -1033,7 +1033,7 @@ pub fn setup_core<O>(module_paths: &[&str]) ->
 
   if !opts.no_bwrap {
     reinvoke_via_bwrap(
-      &opts, &current_exe,
+      opts, &current_exe,
       &mut |s: &OsStr| s.to_str().unwrap().starts_with("--test=")
     )
       .context("reinvoke via bwrap")?;
@@ -1043,7 +1043,7 @@ pub fn setup_core<O>(module_paths: &[&str]) ->
   sleep(opts.pause.into());
 
   let cln = cleanup_notify::Handle::new()?;
-  let ds = prepare_tmpdir(&opts, &current_exe)?;
+  let ds = prepare_tmpdir(opts, &current_exe)?;
 
   let (mgmt_conn, server_child) =
     prepare_gameserver(&cln, &ds).did("setup game server")?;
index 83346a952759df92ce9e437b8981f57fe74d8472..cdc6fc0009fa0e3dd6ff8849e3c0deca6d63bf03 100644 (file)
@@ -34,3 +34,5 @@
 -A clippy::manual_split_once
 -A clippy::expect_fun_call
 -A clippy::manual_map
+-A clippy::vec_init_then_push
+-A clippy::collapsible_if
index fbc40c1d2aa85b9fe0949457edea15fdcfa01be1..3e7b36ba4a959d07ca8b8f3925e33fbdd302621b 100644 (file)
@@ -39,9 +39,9 @@ use otter::prelude::*;
 const CT_JAVASCRIPT: mime::Mime = mime::APPLICATION_JAVASCRIPT_UTF_8;
 const CT_TEXT:      mime::Mime = mime::TEXT_PLAIN_UTF_8;
 const CT_HTML:      mime::Mime = mime::TEXT_HTML_UTF_8;
-const CT_ZIP: &'static str = "application/zip";
-const CT_GZIP: &'static str = "application/gzip";
-const CT_WASM: &'static str = "application/wasm";
+const CT_ZIP: &str = "application/zip";
+const CT_GZIP: &str = "application/gzip";
+const CT_WASM: &str = "application/wasm";
 
 trait IntoMime: Debug {
   fn into_mime(&self) -> mime::Mime;
@@ -104,7 +104,7 @@ impl Templates {
 enum ResourceLocation { Main, Wasm(&'static str), }
 type RL = ResourceLocation;
 
-const RESOURCES: &[(&'static str, ResourceLocation, ConstContentType)] = &[
+const RESOURCES: &[(&str, ResourceLocation, ConstContentType)] = &[
   ("script.js",    RL::Main,                       &CT_JAVASCRIPT),
   ("LICENCE",      RL::Main,                       &CT_TEXT),
   ("libre",        RL::Main,                       &CT_HTML),
@@ -381,7 +381,7 @@ async fn r_bundle(path: Path<(
     .set_content_type(ctype.into_mime())
 }
 
-const FILES_PATH: &'static str = "/_/src";
+const FILES_PATH: &str = "/_/src";
 
 #[derive(Error)]
 #[error("actix Files produced improper response: {0}")]
index b34b83e4c88e21688047311bb1cc5ba85e8f0cb3..cc14595044543bcc7a9608ba0860f684745f5a50 100644 (file)
@@ -166,9 +166,9 @@ fn session_inner(form: Json<SessionForm>,
       };
 
       let for_piece = SessionPieceContext {
+        pos,
         z: zlevel.clone(),
         id: pri.vpid,
-        pos: pos,
         info: serde_json::to_string(&for_info)
           .map_err(|e| InternalError::JSONEncode(e))?,
       };
index dac2a454a50d3b769d306780451dd4b88904b3a1..5d2da22fe91efc23f9dce2ad8110a2e628e064b7 100644 (file)
@@ -230,7 +230,7 @@ fn main() {
 
   for libs in opts.libs.split(SPLIT) {
     let tlibs = Config1::PathGlob(libs.to_owned());
-    load_global_libs(&vec![tlibs.clone()])?;
+    load_global_libs(&[tlibs.clone()])?;
   }
   let mut items: Vec<ItemForOutput> = default();
   let ig_dummy = Instance::dummy();