Skip to content

Commit bc9f7d2

Browse files
committed
fix: Avoid pattern exprs in range patterns during mutation generation
1 parent f6f20bf commit bc9f7d2

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

mutest-emit/src/codegen/mutation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ impl<'tcx, 'ast, 'op, 'trg, 'm> ast::visit::Visitor<'ast> for MutationCollector<
539539
// NOTE: We do not want to visit pattern expressions (i.e. literal, const block, path), since
540540
// we cannot introduce dynamic mutations in them.
541541
ast::PatKind::Expr(_) => {}
542+
// NOTE: We do not want to visit range patterns, since
543+
// we cannot introduce dynamic mutations in them.
544+
ast::PatKind::Range(_, _, _) => {}
542545
_ => ast::visit::walk_pat(self, pat),
543546
}
544547
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ build
22
//@ stderr: empty
33

4-
fn mutable_fn(c @ ('Z' | _): char) {
4+
fn mutable_fn_with_pat_exprs(c @ ('Z' | _): char) {
55
if let 'Z' | 'z' = c {}
66

77
match c {
@@ -11,7 +11,15 @@ fn mutable_fn(c @ ('Z' | _): char) {
1111
}
1212
}
1313

14+
fn mutable_fn_with_range_pats(name: &str) -> bool {
15+
if let b'a'..=b'i' | b'k'..=b'y' | b'A'..=b'I' | b'K'..=b'Y' = name.as_bytes()[0] {
16+
return true;
17+
}
18+
false
19+
}
20+
1421
#[test]
1522
fn test() {
16-
mutable_fn('Z');
23+
mutable_fn_with_pat_exprs('Z');
24+
mutable_fn_with_range_pats("abc");
1725
}

0 commit comments

Comments
 (0)