diff --git a/Cargo.toml b/Cargo.toml index 50062118d3..819f417c14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,6 +135,7 @@ testutils = { path = "lib/testutils" } [workspace.lints.clippy] explicit_iter_loop = "deny" implicit_clone = "deny" +redundant_else = "deny" semicolon_if_nothing_returned = "deny" uninlined_format_args = "deny" diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 301e9b2382..bd0c031c73 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -3009,15 +3009,13 @@ fn resolve_aliases( string_args.extend_from_slice(&alias_args); resolved_aliases.insert(alias_name.clone()); continue; - } else { - return Err(user_error(format!( - r#"Alias definition for "{alias_name}" must be a string list"# - ))); } - } else { - // Not a real command and not an alias, so return what we've resolved so far - return Ok(string_args); + return Err(user_error(format!( + r#"Alias definition for "{alias_name}" must be a string list"# + ))); } + // Not a real command and not an alias, so return what we've resolved so far + return Ok(string_args); } } // No more alias commands, or hit unknown option diff --git a/cli/src/commands/file/untrack.rs b/cli/src/commands/file/untrack.rs index 97752226b0..933d024f99 100644 --- a/cli/src/commands/file/untrack.rs +++ b/cli/src/commands/file/untrack.rs @@ -97,11 +97,10 @@ pub(crate) fn cmd_file_untrack( "Files that are not ignored will be added back by the next command. Make sure they're ignored, then try again.", )); - } else { - // This means there were some concurrent changes made in the working copy. We - // don't want to mix those in, so reset the working copy again. - locked_ws.locked_wc().reset(&new_commit)?; } + // This means there were some concurrent changes made in the working copy. We + // don't want to mix those in, so reset the working copy again. + locked_ws.locked_wc().reset(&new_commit)?; } let num_rebased = tx.repo_mut().rebase_descendants(command.settings())?; if num_rebased > 0 { diff --git a/cli/src/commands/workspace/.add.rs.swp b/cli/src/commands/workspace/.add.rs.swp new file mode 100644 index 0000000000..9581019b57 Binary files /dev/null and b/cli/src/commands/workspace/.add.rs.swp differ diff --git a/cli/src/commands/workspace/add.rs b/cli/src/commands/workspace/add.rs index 0d61d99b50..e761399c6c 100644 --- a/cli/src/commands/workspace/add.rs +++ b/cli/src/commands/workspace/add.rs @@ -85,9 +85,8 @@ pub fn cmd_workspace_add( let destination_path = command.cwd().join(&args.destination); if destination_path.exists() { return Err(user_error("Workspace already exists")); - } else { - fs::create_dir(&destination_path).context(&destination_path)?; } + fs::create_dir(&destination_path).context(&destination_path)?; let name = if let Some(name) = &args.name { name.to_string() } else { diff --git a/lib/src/default_index/rev_walk.rs b/lib/src/default_index/rev_walk.rs index 43ff667bf1..0a4bf974a9 100644 --- a/lib/src/default_index/rev_walk.rs +++ b/lib/src/default_index/rev_walk.rs @@ -526,10 +526,9 @@ impl RevWalk for RevWalkImpl { // No more wanted entries to walk debug_assert!(!self.queue.items.iter().any(|x| x.is_wanted())); return None; - } else { - self.queue - .extend_unwanted(index.adjacent_positions(item.pos)); } + self.queue + .extend_unwanted(index.adjacent_positions(item.pos)); } debug_assert_eq!( diff --git a/lib/src/default_index/store.rs b/lib/src/default_index/store.rs index de5b7f3191..8c516a0dec 100644 --- a/lib/src/default_index/store.rs +++ b/lib/src/default_index/store.rs @@ -354,9 +354,7 @@ impl IndexStore for DefaultIndexStore { ); } ReadonlyIndexLoadError::Other { name: _, error } => { - eprintln!( - "{err} (maybe the format has changed): {error}. Reindexing..." - ); + eprintln!("{err} (maybe the format has changed): {error}. Reindexing..."); } } self.reinit().map_err(|err| IndexReadError(err.into()))?; diff --git a/lib/src/file_util.rs b/lib/src/file_util.rs index 12c83afe9c..548ebcae4c 100644 --- a/lib/src/file_util.rs +++ b/lib/src/file_util.rs @@ -92,13 +92,13 @@ pub fn relative_path(from: &Path, to: &Path) -> PathBuf { // Find common prefix. for (i, base) in from.ancestors().enumerate() { if let Ok(suffix) = to.strip_prefix(base) { - if i == 0 && suffix.as_os_str().is_empty() { - return ".".into(); + return if i == 0 && suffix.as_os_str().is_empty() { + ".".into() } else { let mut result = PathBuf::from_iter(iter::repeat("..").take(i)); result.push(suffix); - return result; - } + result + }; } } diff --git a/lib/src/merged_tree.rs b/lib/src/merged_tree.rs index 81090aedb0..45db0a2a14 100644 --- a/lib/src/merged_tree.rs +++ b/lib/src/merged_tree.rs @@ -783,9 +783,8 @@ impl Iterator for TreeDiffIterator<'_> { path, values: Ok((before, after)), }); - } else { - unreachable!(); } + unreachable!(); } }; diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 1cadb9ce9a..36b9c60463 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -212,12 +212,12 @@ impl OpStore for SimpleOpStore { let hex_prefix = prefix.hex(); if hex_prefix.len() == OPERATION_ID_LENGTH * 2 { // Fast path for full-length ID - if matches_root || op_dir.join(hex_prefix).try_exists()? { + return Ok(if matches_root || op_dir.join(hex_prefix).try_exists()? { let id = OperationId::from_bytes(prefix.as_full_bytes().unwrap()); - return Ok(PrefixResolution::SingleMatch(id)); + PrefixResolution::SingleMatch(id) } else { - return Ok(PrefixResolution::NoMatch); - } + PrefixResolution::NoMatch + }); } let mut matched = matches_root.then(|| self.root_operation_id.clone());