Skip to content

Commit 627720b

Browse files
committed
clippy cleanups
1 parent ede72a3 commit 627720b

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/in_diff.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn diff_filter_file(
9090

9191
/// Filter a list of mutants to those intersecting a diff on the file tree.
9292
pub fn diff_filter(mutants: Vec<Mutant>, diff_text: &str) -> Result<Vec<Mutant>, DiffFilterError> {
93-
let patches = match flickzeug::patch_from_str(&diff_text) {
93+
let patches = match flickzeug::patch_from_str(diff_text) {
9494
Ok(patches) => patches,
9595
Err(err) => return Err(DiffFilterError::InvalidDiff(err.to_string())), // squash to a string to simplify lifetimes
9696
};
@@ -103,7 +103,7 @@ pub fn diff_filter(mutants: Vec<Mutant>, diff_text: &str) -> Result<Vec<Mutant>,
103103
let mut lines_changed_by_path: HashMap<&Utf8Path, Vec<usize>> = HashMap::new();
104104
let mut changed_rs_file = false;
105105
for patch in &patches {
106-
let path = strip_patch_path(&patch.modified().unwrap_or_default());
106+
let path = strip_patch_path(patch.modified().unwrap_or_default());
107107
if path != "/dev/null" && path.extension() == Some("rs") {
108108
changed_rs_file = true;
109109
lines_changed_by_path
@@ -224,7 +224,7 @@ fn affected_lines(diff: &Diff<str>) -> Vec<usize> {
224224
Line::Insert(_) | Line::Context(_) => {
225225
if prev_removed {
226226
debug_assert!(
227-
affected_lines.last().map_or(true, |last| *last < lineno),
227+
affected_lines.last().is_none_or(|last| *last < lineno),
228228
"{lineno} {affected_lines:?}"
229229
);
230230
debug_assert!(lineno >= 1, "{lineno}");
@@ -238,7 +238,7 @@ fn affected_lines(diff: &Diff<str>) -> Vec<usize> {
238238
lineno += 1;
239239
}
240240
Line::Insert(_) => {
241-
if affected_lines.last().map_or(true, |last| *last != lineno) {
241+
if affected_lines.last().is_none_or(|last| *last != lineno) {
242242
affected_lines.push(lineno);
243243
}
244244
lineno += 1;
@@ -247,7 +247,7 @@ fn affected_lines(diff: &Diff<str>) -> Vec<usize> {
247247
if lineno > 1
248248
&& affected_lines
249249
.last()
250-
.map_or(true, |last| *last != (lineno - 1))
250+
.is_none_or(|last| *last != (lineno - 1))
251251
{
252252
affected_lines.push(lineno - 1);
253253
}
@@ -352,7 +352,7 @@ index eb42779..a0091b7 100644
352352
assert_eq!(err.unwrap_err().exit_code(), 0);
353353
}
354354

355-
/// https://github.com/sourcefrog/cargo-mutants/issues/580
355+
/// <https://github.com/sourcefrog/cargo-mutants/issues/580>
356356
#[test]
357357
fn parse_diff_with_only_moves() {
358358
let diff_str = "\
@@ -380,9 +380,9 @@ rename to test-utils/src/write.rs
380380
// Assert our diff library, Flickzeug, doesn't break on this
381381
let diffs = flickzeug::patch_from_str(diff_str).unwrap();
382382
assert_eq!(diffs.len(), 5);
383-
diffs.iter().for_each(|diff| {
383+
for diff in &diffs {
384384
assert_eq!(diff.hunks().len(), 0);
385-
});
385+
}
386386
let err = diff_filter(Vec::new(), diff_str);
387387
assert_eq!(err, Err(DiffFilterError::NoMutants));
388388
}
@@ -397,7 +397,7 @@ Binary files target/release/cargo-mutants and target/debug/cargo-mutants differ
397397
let err = diff_filter(Vec::new(), diff_str);
398398
assert_matches!(
399399
err,
400-
Err(DiffFilterError::EmptyDiff) | Err(DiffFilterError::NoSourceFiles)
400+
Err(DiffFilterError::EmptyDiff | DiffFilterError::NoSourceFiles)
401401
);
402402
}
403403

src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl Options {
462462
// TODO: Use Option::is_none_or when MSRV>1.80
463463
self.examine_globset
464464
.as_ref()
465-
.map_or(true, |g| g.is_match(path))
465+
.is_none_or(|g| g.is_match(path))
466466
&& !self
467467
.exclude_globset
468468
.as_ref()

src/scenario.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::Mutant;
77

88
/// A scenario is either a freshening build in the source tree, a baseline test with no mutations, or a mutation test.
99
#[derive(Clone, Eq, PartialEq, Debug, Serialize)]
10+
#[allow(clippy::large_enum_variant)]
1011
pub enum Scenario {
1112
/// Build in a copy of the source tree but with no mutations applied.
1213
Baseline,

0 commit comments

Comments
 (0)